zengyf 2 anni fa
parent
commit
98571c13eb

+ 73 - 1
src/main/java/com/steerinfo/dil/controller/AmsContractTruckPriceController.java

@@ -44,7 +44,6 @@ public class AmsContractTruckPriceController extends BaseRESTfulController {
     @Autowired
     IAmsContractTruckPriceService amsContractTruckPriceService;
 
-
     @Autowired
     ColumnDataFeign columnDataFeign;
 
@@ -257,6 +256,79 @@ public class AmsContractTruckPriceController extends BaseRESTfulController {
         return success(salePriceList);
     }
 
+    @ApiOperation(value="查询汽运单价信息")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "apiId(519)", value = "表头", required = false, dataType = "Interger")
+    })
+    @PostMapping("/updatenewdata")
+    public RESTfulResult updatenewdata(@RequestBody(required=false) Map<String,Object> mapValue,
+                                                               Integer apiId,
+                                                               Integer pageNum,
+                                                               Integer pageSize,
+                                                               String con,String userId) throws ParseException {
+        if (con != null && !con.equals("undefined")) {
+            mapValue.put("con","%" + con + "%");
+        }else {
+            mapValue.put("con","%" +"%");
+        }
+//        if (userId != null && !userId.equals("undefined")) {
+//            //查询承运商ID
+//           String carrierName1 = amsContractTruckPriceService.getCarrierNameForDetail(userId);
+//           mapValue.put("carrierName1","%" + carrierName1 + "%");
+//        }
+        //1.先查询出收货地址的所有收货ID
+        List<Map<String, Object>> receiveAddress = amsContractTruckPriceService.getReceiveAddressId(mapValue);
+        //2.查询出该收货所有的单价信息
+        List<Map<String, Object>> saleOrderList = amsContractTruckPriceService.getAmsContractTransportPriceForDetail(mapValue);
+        //3.遍历查询出最近的单价信息
+        List<Map<String,Object>> salePriceList=new LinkedList<>();
+        //格式化
+        SimpleDateFormat simpleDateFormat=new SimpleDateFormat("yyyy-MM-dd");
+        //获取数据的订单时间
+        Date orderTime = simpleDateFormat.parse((String) mapValue.get("orderTime"));
+        //最近的留下
+        for (Map<String, Object> address : receiveAddress) {
+            String address1 = (String) address.get("address");
+            //BigDecimal placeId = bigDecimal;
+            Map<String,Object> map1=new HashMap<>();
+            int flag=0;
+            for (Map<String, Object> stringObjectMap : saleOrderList) {
+                String address2 = (String) stringObjectMap.get("address");
+                //单价的执行日期
+                Date priceDate = (Date) stringObjectMap.get("priceDate");
+                if (address2 ==null||priceDate==null){
+                    continue;
+                }
+                String format = simpleDateFormat.format(priceDate);
+                Date parse = simpleDateFormat.parse(format);
+                //Date parse1 = simpleDateFormat.parse("2022-12-10")
+                if (parse.before(orderTime)||parse.equals(orderTime)){
+                    if (address2.equals(address1)){
+                        flag=1;
+                        if (map1.size()==0){
+                            map1.putAll(stringObjectMap);
+                        }else{
+                            //比较日期(如果日期在存入的日期之后,则存入该日期)
+                            Date priceDate1 = (Date) map1.get("priceDate");
+                            String format1 = simpleDateFormat.format(priceDate1);
+                            Date parse1 = simpleDateFormat.parse(format1);
+                            if (parse.after(parse1)){
+                                map1.clear();
+                                map1.putAll(stringObjectMap);
+                            }
+                        }
+                    }
+                }
+            }
+            if (flag==1){
+                BigDecimal priceid = (BigDecimal) map1.get("priceid");
+                amsContractTruckPriceMapper.updateDeletedTemplate(priceid);
+                salePriceList.add(map1);
+            }
+        }
+        return success(salePriceList);
+    }
+
     @ApiOperation(value="查询内转汽运单价信息")
     @ApiImplicitParams({
             @ApiImplicitParam(name = "apiId(109)", value = "表头", required = false, dataType = "Interger")

+ 7 - 2
src/main/java/com/steerinfo/dil/mapper/AmsContractTruckPriceMapper.java

@@ -46,6 +46,8 @@ public interface AmsContractTruckPriceMapper extends IBaseMapper<AmsContractTran
     String getCarrierNameForDetail(String userId);
     //获取收货地址的信息
     List<Map<String,Object>> getReceiveAddressId(Map<String,Object> map);
+    //改deleted为1
+    int updateDeletedTemplate(BigDecimal priceId);
     //获取已经计算出的单价值
     AmsContractTransportPrice getOnePriceMap(Map<String,Object> map);
     //获取汽运单价信息
@@ -123,6 +125,9 @@ public interface AmsContractTruckPriceMapper extends IBaseMapper<AmsContractTran
 
     List<Map<String, Object>> getPriceValueListInward(BigDecimal oilTypeId);
 
-//    //子表信息复制新增、
-//    insertIntoAmsContractForMaterial(BigDecimal priceId);
+    //子表信息复制新增、
+    int insertIntoAmsContractForMaterial(Map<String,Object> map);
+
+    //getAmsContractMaterialData
+    List<Map<String, Object>> getAmsContractMaterialData(BigDecimal priceId);
 }

+ 28 - 25
src/main/java/com/steerinfo/dil/service/impl/AmsContractTruckPriceServiceImpl.java

@@ -358,18 +358,12 @@ public class AmsContractTruckPriceServiceImpl implements IAmsContractTruckPriceS
         BigDecimal type = DataChange.dataToBigDecimal(map.get("type"));
         //根据油品名称ID和非历史油价筛选出符合条件的运价合集
         List<Map<String, Object>> PriceValueList = new ArrayList<>();
-        PriceValueList = amsContractTruckPriceMapper.getPriceValueList(oilTypeId);
-//        if (type.compareTo(new BigDecimal(1)) == 0) {
-//
-//        }else if(type.compareTo(new BigDecimal(2)) == 0) {
-//            PriceValueList = amsContractTruckPriceMapper.getPriceValueListInward(oilTypeId);
-//        }
+        if (type.compareTo(new BigDecimal(1)) == 0) {
+            PriceValueList = amsContractTruckPriceMapper.getPriceValueList(oilTypeId);
+        }else if(type.compareTo(new BigDecimal(2)) == 0) {
+            PriceValueList = amsContractTruckPriceMapper.getPriceValueListInward(oilTypeId);
+        }
         for (Map<String, Object> stringObjectMap : PriceValueList) {
-            //内转的话复制子表信息并新增
-//            if(type.compareTo(new BigDecimal(2)) == 0){
-//                stringObjectMap.get("priceId");
-//                amsContractTruckPriceMapper.
-//            }
             //有距离则是销售钢材
             if (stringObjectMap.get("haulDistance")!=null) {
                 //中标价格或者收货地址(库存)则重新计算价格
@@ -386,17 +380,17 @@ public class AmsContractTruckPriceServiceImpl implements IAmsContractTruckPriceS
                     BigDecimal distance = DataChange.dataToBigDecimal(stringObjectMap.get("haulDistance"));
                     if (zbDistance != null && distance != null && zbDistance.intValue()!=0 && distance.intValue()!=0){
                         BigDecimal subtract = zbDistance.subtract(distance);
-                        if (subtract.intValue()>10 || subtract.intValue()<-10){
-                            //大于正负10km重新计算价格
-                            //跳过
-                            continue;
-                        }else{
-                            //小于10km取中标价格
-                            /*Map<String,Object> updatePrice=new HashMap<>();
-                            updatePrice.put("priceId",DataChange.dataToBigDecimal(stringObjectMap.get("priceId")));
-                            updatePrice.put("priceValue",DataChange.dataToBigDecimal(zb.get("priceValue")));
-                            return amsContractTruckPriceMapper.updateByPriceId(updatePrice);*/
-                        }
+//                        if (subtract.intValue()>10 || subtract.intValue()<-10){
+//                            //大于正负10km重新计算价格
+//                            //跳过
+//                            continue;
+//                        }else{
+//                            //小于10km取中标价格
+//                            /*Map<String,Object> updatePrice=new HashMap<>();
+//                            updatePrice.put("priceId",DataChange.dataToBigDecimal(stringObjectMap.get("priceId")));
+//                            updatePrice.put("priceValue",DataChange.dataToBigDecimal(zb.get("priceValue")));
+//                            return amsContractTruckPriceMapper.updateByPriceId(updatePrice);*/
+//                        }
                     }
                 }
             }
@@ -415,10 +409,10 @@ public class AmsContractTruckPriceServiceImpl implements IAmsContractTruckPriceS
                 try{
                     if(newOilPrice.compareTo(oilpriceBase)==-1){
                         //直接降低油价
-                        i+=addANewAmsContractTransportPrice(stringObjectMap,n,newOilPrice);
+                        i+=addANewAmsContractTransportPrice(stringObjectMap,n,newOilPrice,type);
                     }else if (newOilPrice.compareTo(oilpriceBase)==1 && "1".equals(flag)){
                         //加上两个判断之后
-                        i+=addANewAmsContractTransportPrice(stringObjectMap,n,newOilPrice);
+                        i+=addANewAmsContractTransportPrice(stringObjectMap,n,newOilPrice,type);
                     }
                 }catch (Exception e){
                     e.printStackTrace();
@@ -461,7 +455,7 @@ public class AmsContractTruckPriceServiceImpl implements IAmsContractTruckPriceS
      * @throws Exception
      */
     @Transactional
-    public int addANewAmsContractTransportPrice(Map<String, Object> stringObjectMap,BigDecimal n,BigDecimal newOilPrice) throws ParseException {
+    public int addANewAmsContractTransportPrice(Map<String, Object> stringObjectMap,BigDecimal n,BigDecimal newOilPrice,BigDecimal type) throws ParseException {
         //定义将要改变的执行价
         BigDecimal nowPriceValue;
         //存储原运输单价实绩对象
@@ -478,6 +472,15 @@ public class AmsContractTruckPriceServiceImpl implements IAmsContractTruckPriceS
         AmsContractTransportPrice amsContractTransportPrice = amsContractTruckPriceMapper.selectByPrimaryKey(priceId);
         //生成主键
         BigDecimal i = amsContractTruckPriceMapper.selectMaxId();
+        //内转的话复制子表信息并新增
+        if(type.compareTo(new BigDecimal(2)) == 0){
+            List<Map<String, Object>> amsContractMaterialData = amsContractTruckPriceMapper.getAmsContractMaterialData(priceId);
+            for (Map<String, Object> amsContractMaterialDatum : amsContractMaterialData) {
+                amsContractMaterialDatum.put("i",i);
+                amsContractMaterialDatum.put("priceMaterialId",amsContractTruckPriceMapper.selectPriceMaterialMaxId());
+                amsContractTruckPriceMapper.insertIntoAmsContractForMaterial(amsContractMaterialDatum);
+            }
+        }
         //如果是钢材的单价那么就需要改变吨公里
         amsContractTransportPrice.setPriceId(i);
         //生成执行日期

+ 19 - 1
src/main/resources/com/steerinfo/dil/mapper/AmsContractTruckPriceMapper.xml

@@ -992,6 +992,12 @@
                            WHERE  ACTP.DELETED=0)
   </select>
 
+  <update id="updateDeletedTemplate">
+    update AMS_CONTRACT_TRANSPORT_PRICE ACTP
+    set ACTP.DELETED=0
+    WHERE ACTP.PRICE_ID=#{priceId}
+</update>
+
   <!--获取全部承运商的信息-->
   <select id="getCarrierListByPrice" resultType="java.util.LinkedHashMap">
     select p0.*,(SELECT COUNT(*) "total" FROM RMS_CARRIER RC) "total" from (select RC.CARRIER_NAME "carrierName",RC.CARRIER_ID "carrierId",ROWNUM r
@@ -1337,6 +1343,10 @@
     from AMS_CONTRACT_TRANSPORT_PRICE a_t_price
     where a_t_price.OIL_TYPE_ID = #{oilTypeId} and a_t_price.DELETED = 0
     and a_t_price.type=1
+    and to_date(to_char(a_t_price.price_date,'yyyy-mm-dd'),'yyyy-mm-dd')
+    >=to_date('2022-12-07','yyyy-mm-dd')
+    and to_date(to_char(a_t_price.price_date,'yyyy-mm-dd'),'yyyy-mm-dd')
+    <![CDATA[<]]>=to_date('2022-12-07','yyyy-mm-dd')
     order by reference_ht desc
   </select>
 
@@ -1615,9 +1625,17 @@
     order by a_t_price.PRICE_ID desc
   </select>
 
+  <select id="getAmsContractMaterialData" resultType="java.util.LinkedHashMap">
+    select ACPM.MATERIAL_ID "materialId" FROM AMS_CONTAACT_PRICE_MATERIAL ACPM
+    WHERE ACPM.PRICE_ID=#{priceId} AND ACPM.DELETED=0
+  </select>
+
   <insert id="insertIntoAmsContractForMaterial">
-    insert into 
+    insert into AMS_CONTAACT_PRICE_MATERIAL
+      (PRICE_MATERIAL_ID,MATERIAL_ID,PRICE_ID,DELETED)
+    VALUES(#{priceMaterialId},#{materialId},#{i},1)
   </insert>
+
   <insert id="insertshdz" parameterType="map">
     insert into RMS_RECEIVE_ADDRESS (ADDRESS_ID, ADDRESS_PROVINCE, ADDRESS_DISTRICT
     <if test="addressTown!=null">

+ 3 - 2
src/main/resources/com/steerinfo/dil/mapper/DilNoticeMapper.xml

@@ -462,8 +462,9 @@
       </if>
       <if test="insertTime!= null">
         and
-        <foreach collection="insertTime" item="item" open="(" separator="," close=")">
-          "insertTime" in #{item}
+        <foreach collection="insertTime" item="item" open="(" separator="or" close=")">
+          to_date(to_char("insertTime",'yyyy-mm-dd hh24:mi:ss'),'yyyy-mm-dd hh24:mi:ss')
+          in to_date(#{item},'yyyy-mm-dd hh24:mi:ss')
         </foreach>
       </if>