|
@@ -3,7 +3,9 @@ package com.steerinfo.dil.controller;
|
|
import com.steerinfo.dil.feign.ColumnDataFeign;
|
|
import com.steerinfo.dil.feign.ColumnDataFeign;
|
|
import com.steerinfo.dil.feign.ESFeign;
|
|
import com.steerinfo.dil.feign.ESFeign;
|
|
import com.steerinfo.dil.mapper.AmsContractTruckPriceMapper;
|
|
import com.steerinfo.dil.mapper.AmsContractTruckPriceMapper;
|
|
|
|
+import com.steerinfo.dil.mapper.RmsReceivePlaceMapper;
|
|
import com.steerinfo.dil.model.AmsContractTransportPrice;
|
|
import com.steerinfo.dil.model.AmsContractTransportPrice;
|
|
|
|
+import com.steerinfo.dil.model.RmsReceivePlace;
|
|
import com.steerinfo.dil.service.IAmsContractTruckPriceService;
|
|
import com.steerinfo.dil.service.IAmsContractTruckPriceService;
|
|
import com.steerinfo.dil.util.BaseRESTfulController;
|
|
import com.steerinfo.dil.util.BaseRESTfulController;
|
|
import com.steerinfo.dil.util.ColumnDataUtil;
|
|
import com.steerinfo.dil.util.ColumnDataUtil;
|
|
@@ -56,16 +58,149 @@ public class AmsContractTruckPriceController extends BaseRESTfulController {
|
|
@Autowired
|
|
@Autowired
|
|
AmsContractTruckPriceMapper amsContractTruckPriceMapper;
|
|
AmsContractTruckPriceMapper amsContractTruckPriceMapper;
|
|
|
|
|
|
- /*@ApiOperation(value="导入单价的数据写入数据库")
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ RmsReceivePlaceMapper rmsReceivePlaceMapper;
|
|
|
|
+
|
|
|
|
+ @ApiOperation(value="导入单价的数据写入数据库")
|
|
@PostMapping("/importDataForAmsContractTransportPrice")
|
|
@PostMapping("/importDataForAmsContractTransportPrice")
|
|
- public RESTfulResult importDataForAmsContractTransportPrice(@RequestBody(required = false) List<Map<String,Object>> mapList){
|
|
|
|
|
|
+ public RESTfulResult importDataForAmsContractTransportPrice(@RequestBody(required = false) List<Map<String,Object>> mapList,
|
|
|
|
+ BigDecimal importPriceValue,String importPriceDate) throws ParseException {
|
|
//mapList为导入的数据,遍历导入进来的数据,如果数据存在在单价当中则将旧单价改为1,新增单价为0
|
|
//mapList为导入的数据,遍历导入进来的数据,如果数据存在在单价当中则将旧单价改为1,新增单价为0
|
|
//如果数据查找不到就在收货地址表新增地址,在新增单价
|
|
//如果数据查找不到就在收货地址表新增地址,在新增单价
|
|
//1.查询所有单价数据
|
|
//1.查询所有单价数据
|
|
- amsContractTruckPriceMapper
|
|
|
|
|
|
+ //所有时间定为统一的值
|
|
|
|
+ Date date=new Date();
|
|
|
|
+ SimpleDateFormat simpleDateFormat=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
for (Map<String, Object> stringObjectMap : mapList) {
|
|
for (Map<String, Object> stringObjectMap : mapList) {
|
|
|
|
+ String address="";
|
|
|
|
+ String addressProvince="";
|
|
|
|
+ String addressDistrict="";
|
|
|
|
+ String addressDdp="";
|
|
|
|
+ //省份
|
|
|
|
+ String s = (String) stringObjectMap.get("addressProvince");
|
|
|
|
+ if(s!=null){
|
|
|
|
+ addressProvince= s.replaceAll("省", "");
|
|
|
|
+ }
|
|
|
|
+ //市
|
|
|
|
+ String s1 = (String) stringObjectMap.get("addressDistrict");
|
|
|
|
+ if(s1!=null){
|
|
|
|
+ addressDistrict = s1.replaceAll("市", "");
|
|
|
|
+ }
|
|
|
|
+ //县
|
|
|
|
+ String addressTown = (String) stringObjectMap.get("addressTown");
|
|
|
|
+ if (addressTown==null){
|
|
|
|
+ addressTown=addressDistrict;
|
|
|
|
+ addressDistrict=addressProvince;
|
|
|
|
+ }
|
|
|
|
+ //具体地址
|
|
|
|
+ String addressDeliveryAddress = (String) stringObjectMap.get("addressDeliveryAddress");
|
|
|
|
+ if (addressDeliveryAddress==null){
|
|
|
|
+ addressDeliveryAddress=addressTown;
|
|
|
|
+ }
|
|
|
|
+ //单价价格
|
|
|
|
+ BigDecimal priceValue = DataChange.dataToBigDecimal(stringObjectMap.get("priceValue"));
|
|
|
|
+ if (priceValue==null){
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ //参考运距
|
|
|
|
+ BigDecimal haulDistance = DataChange.dataToBigDecimal(stringObjectMap.get("haulDistance"));
|
|
|
|
+ //吨/公里
|
|
|
|
+ BigDecimal priceTonKilometer = DataChange.dataToBigDecimal(stringObjectMap.get("priceTonKilometer"));
|
|
|
|
+ //1.把省市县地址合起来
|
|
|
|
+ addressDdp="%"+addressProvince+addressDistrict+addressTown+"%";
|
|
|
|
+ //2.把所有地址合起来
|
|
|
|
+ address="%"+addressProvince+addressDistrict+addressTown+addressDeliveryAddress+"%";
|
|
|
|
+ //把地址去数据库查询数据
|
|
|
|
+ Map<String, Object> amsPriceForImport = amsContractTruckPriceMapper.getAmsContractTransportPriceForImport(address);
|
|
|
|
+ //旧单价
|
|
|
|
+ BigDecimal priceId=BigDecimal.ZERO;
|
|
|
|
+ BigDecimal placeId=BigDecimal.ZERO;
|
|
|
|
+ if (amsPriceForImport!=null){
|
|
|
|
+ if (amsPriceForImport.get("priceId")!=null){
|
|
|
|
+ priceId= DataChange.dataToBigDecimal(amsPriceForImport.get("priceId"));
|
|
|
|
+ }
|
|
|
|
+ placeId= DataChange.dataToBigDecimal(amsPriceForImport.get("placeId"));
|
|
|
|
+ }
|
|
|
|
+ BigDecimal addressId = amsContractTruckPriceMapper.getAddressIdForImport(addressDdp);
|
|
|
|
+ //如果区都没有的话就要把区给加上
|
|
|
|
+ if (addressId==null){
|
|
|
|
+ amsContractTruckPriceMapper.insertIntoRRAForImport(addressProvince,addressDistrict,addressTown);
|
|
|
|
+ }
|
|
|
|
+ //新增单价的数据
|
|
|
|
+ //新增的运输类型
|
|
|
|
+ AmsContractTransportPrice amsContractTransportPrice = new AmsContractTransportPrice();
|
|
|
|
+ //生成主键id
|
|
|
|
+ amsContractTransportPrice.setType(new BigDecimal(1));
|
|
|
|
+ amsContractTransportPrice.setInsertUsername("admin");
|
|
|
|
+ amsContractTransportPrice.setInsertTime(date);
|
|
|
|
+ amsContractTransportPrice.setUpdateUsername("admin");
|
|
|
|
+ amsContractTransportPrice.setUpdateTime(date);
|
|
|
|
+ amsContractTransportPrice.setInsertUpdateRemark("无");
|
|
|
|
+ amsContractTransportPrice.setDeleted(new BigDecimal(0));
|
|
|
|
+ amsContractTransportPrice.setShipperId(new BigDecimal(1));
|
|
|
|
+ amsContractTransportPrice.setOilpriceChangeThreshold(new BigDecimal(0.05));
|
|
|
|
+ amsContractTransportPrice.setOilTypeId(new BigDecimal(10));
|
|
|
|
+ amsContractTransportPrice.setCargonameId(new BigDecimal(14));
|
|
|
|
+ amsContractTransportPrice.setPriceValue(priceValue);
|
|
|
|
+ amsContractTransportPrice.setPriceDate(simpleDateFormat.parse(importPriceDate));
|
|
|
|
+ amsContractTransportPrice.setOilpriceBase(importPriceValue);
|
|
|
|
+ if (haulDistance!=null){
|
|
|
|
+ amsContractTransportPrice.setHaulDistance(haulDistance);
|
|
|
|
+ }
|
|
|
|
+ if (priceTonKilometer!=null){
|
|
|
|
+ amsContractTransportPrice.setPriceTonKilometer(priceTonKilometer);
|
|
|
|
+ }
|
|
|
|
+ if (amsPriceForImport==null||amsPriceForImport.get("placeId")==null){
|
|
|
|
+ //2.如果收货地址为空则先新增收货地址再新增单价
|
|
|
|
+ RmsReceivePlace rmsReceivePlace = new RmsReceivePlace();
|
|
|
|
+ rmsReceivePlace.setAddressId(addressId);
|
|
|
|
+ rmsReceivePlace.setAddressDeliveryAddress(addressDeliveryAddress);
|
|
|
|
+ rmsReceivePlace.setPlaceId(rmsReceivePlaceMapper.selectMaxId());
|
|
|
|
+ amsContractTransportPrice.setPlaceId(rmsReceivePlace.getPlaceId());
|
|
|
|
+ rmsReceivePlaceMapper.insertSelective(rmsReceivePlace);
|
|
|
|
+ }else {
|
|
|
|
+ amsContractTransportPrice.setPlaceId(placeId);
|
|
|
|
+ }
|
|
|
|
+ //承运商数据
|
|
|
|
+ String carrierName = (String) stringObjectMap.get("carrierName");
|
|
|
|
+ if (amsPriceForImport!=null&&amsPriceForImport.get("priceId")!=null){
|
|
|
|
+ //1.如果数据不为空(收货地址存在或者单价存在),旧单价置为1,新单价新增
|
|
|
|
+ //旧单价有值才会进行单价
|
|
|
|
+ /*List<BigDecimal> carrierIdForImport = amsContractTruckPriceMapper.getCarrierIdForImport(address);
|
|
|
|
+ for (BigDecimal bigDecimal : carrierIdForImport) {
|
|
|
|
+ amsContractTransportPrice.setCarrierId(bigDecimal);
|
|
|
|
+ }*/
|
|
|
|
+ //旧单价置为1
|
|
|
|
+ amsContractTruckPriceMapper.updateForImport(placeId,simpleDateFormat.format(date));
|
|
|
|
+ if (carrierName!=null){
|
|
|
|
+ String[] split = carrierName.split("/");
|
|
|
|
+ for (String s2 : split) {
|
|
|
|
+ BigDecimal carrierIdForCarrierName = amsContractTruckPriceMapper.getCarrierIdForCarrierName("%" + s2 + "%");
|
|
|
|
+ amsContractTransportPrice.setCarrierId(carrierIdForCarrierName);
|
|
|
|
+ amsContractTransportPrice.setPriceId(amsContractTruckPriceMapper.selectMaxId());
|
|
|
|
+ amsContractTruckPriceMapper.insertSelective(amsContractTransportPrice);
|
|
|
|
+ }
|
|
|
|
+ }else {
|
|
|
|
+ amsContractTransportPrice.setPriceId(amsContractTruckPriceMapper.selectMaxId());
|
|
|
|
+ amsContractTruckPriceMapper.insertSelective(amsContractTransportPrice);
|
|
|
|
+ }
|
|
|
|
+ }else {
|
|
|
|
+ if (carrierName!=null){
|
|
|
|
+ String[] split = carrierName.split("/");
|
|
|
|
+ for (String s2 : split) {
|
|
|
|
+ BigDecimal carrierIdForCarrierName = amsContractTruckPriceMapper.getCarrierIdForCarrierName("%" + s2 + "%");
|
|
|
|
+ amsContractTransportPrice.setCarrierId(carrierIdForCarrierName);
|
|
|
|
+ amsContractTransportPrice.setPriceId(amsContractTruckPriceMapper.selectMaxId());
|
|
|
|
+ amsContractTruckPriceMapper.insertSelective(amsContractTransportPrice);
|
|
|
|
+ }
|
|
|
|
+ }else {
|
|
|
|
+ amsContractTransportPrice.setPriceId(amsContractTruckPriceMapper.selectMaxId());
|
|
|
|
+ amsContractTruckPriceMapper.insertSelective(amsContractTransportPrice);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- }*/
|
|
|
|
|
|
+ return success("导入成功");
|
|
|
|
+ }
|
|
|
|
|
|
@ApiOperation(value="查询汽运单价信息")
|
|
@ApiOperation(value="查询汽运单价信息")
|
|
@ApiImplicitParams({
|
|
@ApiImplicitParams({
|