Browse Source

Merge remote-tracking branch 'origin/master'

hejiahui 2 years ago
parent
commit
5b43e6aad1

+ 20 - 2
src/main/java/com/steerinfo/dil/controller/RmsOilPriceController.java

@@ -23,6 +23,8 @@ import org.apache.shiro.authz.annotation.RequiresPermissions;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
+import java.text.NumberFormat;
+import java.text.ParseException;
 import java.util.*;
 import java.math.BigDecimal;
 
@@ -165,12 +167,28 @@ public class RmsOilPriceController extends BaseRESTfulController {
                                                 Integer pageNum,
                                                 Integer pageSize,
                                                 Integer apiId,
-                                                String con) {
+                                                String con) throws ParseException {
         if (mapValue==null){
             mapValue=new HashMap<>();
         }
         if(con != null && !"".equals(con) && !"null".equals(con)){
-            mapValue.put("index", con);
+            //对包含#以及%的数据进行解析操作
+            if(con.contains("%")){
+                if (con.contains("%23")){
+                    String replace = con.replace("%23", "#");
+                    mapValue.put("index", "%"+replace+"%");
+                }else {
+                    NumberFormat numberFormat = NumberFormat.getPercentInstance();
+                    Number parse = numberFormat.parse(con);
+                    mapValue.put("index", "%"+parse+"%");
+                }
+            }else {
+                if (con.contains("启用")||con.contains("停用")){
+                    mapValue.put("index1", "%"+con+"%");
+                }else {
+                    mapValue.put("index", "%"+con+"%");
+                }
+            }
         }
         PageHelper.startPage(pageNum, pageSize);
         //分页查询数据

+ 20 - 14
src/main/java/com/steerinfo/dil/service/impl/RmsOilPriceServiceImpl.java

@@ -117,7 +117,6 @@ public class RmsOilPriceServiceImpl implements IRmsOilPriceService {
     public int insertOilPrice(Map<String,Object> map) {
         RmsOilPrice rmsOilPrice = new RmsOilPrice();
         rmsOilPrice.setPriceId(rmsOilPriceMapper.selectOilPriceId());
-
         //获取油品ID、油价日期、油价
         BigDecimal oilTypeId = DataChange.dataToBigDecimal(map.get("oilNameId"));
         rmsOilPrice.setPriceOilTypeId(oilTypeId);
@@ -135,21 +134,28 @@ public class RmsOilPriceServiceImpl implements IRmsOilPriceService {
         }
         //如果新增的油价是启用的则关闭该油品之前的已启用的
         Boolean priceStatus = (Boolean) map.get("priceStatus");
-        if(priceStatus && n.compareTo(BigDecimal.ZERO)==-1){
-            if(mesMap != null){
-                map.put("oilTypeId", oilTypeId);
-                rmsOilPriceMapper.closeLastOilPrice(map);
+        if (mesMap == null){
+            if (priceStatus){
+                //设置启用状态
+                rmsOilPrice.setPriceStatus(new BigDecimal(0));
             }
-            //设置启用状态
-            rmsOilPrice.setPriceStatus(new BigDecimal(0));
-            //批量修改油价
-            Map<String, Object> updateMesMap = new HashMap<>();
-            updateMesMap.put("oilTypeId",oilTypeId);
-            updateMesMap.put("newOilPrice", priceValue);
-            amsFeign.batchUpdateTransportPriceByOilPrice1(updateMesMap);
         }else {
-            //否则设置停用状态
-            rmsOilPrice.setPriceStatus(new BigDecimal(1));
+            if(priceStatus && n.compareTo(BigDecimal.ZERO)==-1){
+                if(mesMap != null){
+                    map.put("oilTypeId", oilTypeId);
+                    rmsOilPriceMapper.closeLastOilPrice(map);
+                }
+                //设置启用状态
+                rmsOilPrice.setPriceStatus(new BigDecimal(0));
+                //批量修改油价
+                Map<String, Object> updateMesMap = new HashMap<>();
+                updateMesMap.put("oilTypeId",oilTypeId);
+                updateMesMap.put("newOilPrice", priceValue);
+                amsFeign.batchUpdateTransportPriceByOilPrice1(updateMesMap);
+            }else {
+                //否则设置停用状态
+                rmsOilPrice.setPriceStatus(new BigDecimal(1));
+            }
         }
         rmsOilPrice.setInsertUsername("admin");
         rmsOilPrice.setInsertTime(new Date());

+ 9 - 2
src/main/resources/com/steerinfo/dil/mapper/RmsOilPriceMapper.xml

@@ -411,6 +411,10 @@
     left join RMS_OIL_TYPE ROT
         on ROP.PRICE_OIL_TYPE_ID = ROT.OIL_TYPE_ID
     WHERE ROP.DELETED = 0
+    <if test="index!=null">
+      and ROT.OIL_TYPE_NAME||ROP.PRICE_VALUE
+      ||ROP.FLOATING_SCALE like #{index}
+    </if>
     ORDER BY ROP.INSERT_TIME DESC
     )
     <where>
@@ -433,8 +437,8 @@
       </if>
       <if test="priceDate!= null">
         and
-        <foreach collection="priceDate" item="item" open="(" separator="," close=")">
-          "priceDate" in #{item}
+        <foreach collection="priceDate" item="item" open="(" separator="or" close=")">
+          to_char("priceDate",'yyyy-mm-dd hh24:mi:ss') like '%${item}%'
         </foreach>
       </if>
       <if test="floatingScale!= null">
@@ -449,6 +453,9 @@
           "priceStatus" in #{item}
         </foreach>
       </if>
+      <if test="index1!=null">
+          "priceStatus" like #{index1}
+      </if>
     </where>
     <include refid="orderBy"></include>
   </select>