LIVE_YE 1 rok pred
rodič
commit
691927c8cf

+ 0 - 10
ruoyi-system/src/main/java/com/ruoyi/system/domain/DoumuProductInfo.java

@@ -17,9 +17,6 @@ public class DoumuProductInfo extends BaseEntity
 {
     private static final long serialVersionUID = 1L;
 
-    /** ID */
-    private Long historyId;
-
     private Long productId;
 
     /** 微信标识 */
@@ -118,13 +115,6 @@ public class DoumuProductInfo extends BaseEntity
         this.doumuEvaluate = doumuEvaluate;
     }
 
-    public Long getHistoryId() {
-        return historyId;
-    }
-
-    public void setHistoryId(Long historyId) {
-        this.historyId = historyId;
-    }
 
     public List<DoumuProductFj> getFjList() {
         return fjList;

+ 33 - 59
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/DoumuProductInfoServiceImpl.java

@@ -15,15 +15,16 @@ import com.ruoyi.common.exception.ServiceException;
 import com.ruoyi.common.utils.DateUtils;
 import com.ruoyi.system.domain.DoumuEvaluate;
 import com.ruoyi.system.domain.DoumuProductFj;
+import com.ruoyi.system.domain.DoumuProductHistory;
 import com.ruoyi.system.domain.vo.DoumuProductInfoVo;
-import com.ruoyi.system.mapper.DoumuEvaluateMapper;
-import com.ruoyi.system.mapper.DoumuProductFjMapper;
-import com.ruoyi.system.mapper.SysDictDataMapper;
+import com.ruoyi.system.mapper.*;
+import lombok.SneakyThrows;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
-import com.ruoyi.system.mapper.DoumuProductInfoMapper;
 import com.ruoyi.system.domain.DoumuProductInfo;
 import com.ruoyi.system.service.IDoumuProductInfoService;
+import org.springframework.transaction.annotation.Transactional;
+import utils.ClassUtils;
 
 /**
  * 痘姆古陶信息Service业务层处理
@@ -46,6 +47,9 @@ public class DoumuProductInfoServiceImpl implements IDoumuProductInfoService
     @Autowired
     private DoumuEvaluateMapper doumuEvaluateMapper;
 
+    @Autowired
+    private DoumuProductHistoryMapper doumuProductHistoryMapper;
+
     /**
      * 查询痘姆古陶信息
      *
@@ -95,6 +99,7 @@ public class DoumuProductInfoServiceImpl implements IDoumuProductInfoService
      * @return 结果
      */
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public int insertDoumuProductInfo(DoumuProductInfo doumuProductInfo)
     {
         doumuProductInfo.setOrderNumber("DMGT"+System.currentTimeMillis());
@@ -120,6 +125,8 @@ public class DoumuProductInfoServiceImpl implements IDoumuProductInfoService
      * @return 结果
      */
     @Override
+    @SneakyThrows
+    @Transactional(rollbackFor = Exception.class)
     public int updateDoumuProductInfo(DoumuProductInfo doumuProductInfo)
     {
         doumuProductInfo.setUpdateTime(DateUtils.getNowDate());
@@ -136,9 +143,20 @@ public class DoumuProductInfoServiceImpl implements IDoumuProductInfoService
             }
         }
 
+        //将修改前的数据存入历史记录
+        DoumuProductInfo productInfo = doumuProductInfoMapper.selectDoumuProductInfoByProductId(doumuProductInfo.getProductId());
+        DoumuProductHistory doumuProductHistory = new DoumuProductHistory();
+        ClassUtils.copyProperties(productInfo, doumuProductHistory);
+        doumuProductHistoryMapper.insertDoumuProductHistory(doumuProductHistory);
+
+
         return doumuProductInfoMapper.updateDoumuProductInfo(doumuProductInfo);
     }
 
+
+
+
+
     /**
      * 批量删除痘姆古陶信息
      *
@@ -568,11 +586,11 @@ public class DoumuProductInfoServiceImpl implements IDoumuProductInfoService
         doumuEvaluate.setEndTime(endTime);
         List<DoumuEvaluate> doumuEvaluateList = doumuEvaluateMapper.selectDoumuEvaluateList(doumuEvaluate);
         if(doumuEvaluateList==null || doumuEvaluateList.size()<=0){
-            map.put("fch","0%");
-            map.put("h","0%");
-            map.put("yb","0%");
-            map.put("c","0%");
-            map.put("hc","0%");
+            map.put("fch",0);
+            map.put("h",0);
+            map.put("yb",0);
+            map.put("c",0);
+            map.put("hc",0);
             return AjaxResult.success(map);
         }
         int zs = doumuEvaluateList.size();
@@ -601,56 +619,12 @@ public class DoumuProductInfoServiceImpl implements IDoumuProductInfoService
                     hc++;
                 }
             }
-            map.put("fch","0%");
-            map.put("h","0%");
-            map.put("yb","0%");
-            map.put("c","0%");
-            map.put("hc","0%");
-            if(fch != 0){
-                BigDecimal numFch = new BigDecimal(fch);
-                double result = Double.parseDouble(((numZs.divide(numFch,2,BigDecimal.ROUND_HALF_UP))).toString());
-                // 创建DecimalFormat对象并设置格式化模式为"0%"
-                DecimalFormat decimalFormat = new DecimalFormat("0%");
-                // 使用DecimalFormat对象进行格式化操作
-                String fchBfb = decimalFormat.format((result));
-                map.put("fch",fchBfb);
-            }
-            if(h != 0){
-                BigDecimal numH = new BigDecimal(h);
-                double result = Double.parseDouble(((numZs.divide(numH,2,BigDecimal.ROUND_HALF_UP))).toString());
-                // 创建DecimalFormat对象并设置格式化模式为"0%"
-                DecimalFormat decimalFormat = new DecimalFormat("0%");
-                // 使用DecimalFormat对象进行格式化操作
-                String HBfb = decimalFormat.format((result));
-                map.put("h",HBfb);
-            }
-            if(yb != 0){
-                BigDecimal numYb = new BigDecimal(yb);
-                double result = Double.parseDouble(((numZs.divide(numYb,2,BigDecimal.ROUND_HALF_UP))).toString());
-                // 创建DecimalFormat对象并设置格式化模式为"0%"
-                DecimalFormat decimalFormat = new DecimalFormat("0%");
-                // 使用DecimalFormat对象进行格式化操作
-                String ybBfb = decimalFormat.format((result));
-                map.put("yb",ybBfb);
-            }
-            if(c != 0){
-                BigDecimal numC = new BigDecimal(c);
-                double result = Double.parseDouble(((numZs.divide(numC,2,BigDecimal.ROUND_HALF_UP))).toString());
-                // 创建DecimalFormat对象并设置格式化模式为"0%"
-                DecimalFormat decimalFormat = new DecimalFormat("0%");
-                // 使用DecimalFormat对象进行格式化操作
-                String cBfb = decimalFormat.format((result));
-                map.put("c",cBfb);
-            }
-            if(hc != 0){
-                BigDecimal numHc = new BigDecimal(hc);
-                double result = Double.parseDouble(((numZs.divide(numHc,2,BigDecimal.ROUND_HALF_UP))).toString());
-                // 创建DecimalFormat对象并设置格式化模式为"0%"
-                DecimalFormat decimalFormat = new DecimalFormat("0%");
-                // 使用DecimalFormat对象进行格式化操作
-                String hcBfb = decimalFormat.format((result));
-                map.put("hc",hcBfb);
-            }
+            map.put("fch",fch);
+            map.put("h",h);
+            map.put("yb",yb);
+            map.put("c",c);
+            map.put("hc",hc);
+
         }
         return AjaxResult.success(map);
     }

+ 36 - 0
ruoyi-system/src/main/java/utils/ClassUtils.java

@@ -0,0 +1,36 @@
+package utils;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Modifier;
+
+public class ClassUtils {
+
+    public static <T, S> T copyProperties(S source, T target) throws Exception {
+        Class<?> sourceClass = source.getClass();
+        Class<?> targetClass = target.getClass();
+
+        Field[] sourceFields = sourceClass.getDeclaredFields();
+        for (Field sourceField : sourceFields) {
+            if (Modifier.isFinal(sourceField.getModifiers())){
+                continue;
+            }
+            String fieldName = sourceField.getName();
+            Field targetField = null;
+            try {
+                targetField = targetClass.getDeclaredField(fieldName);
+            } catch (NoSuchFieldException e) {
+                // 目标对象不存在该属性,忽略
+                continue;
+            }
+
+            sourceField.setAccessible(true);
+            targetField.setAccessible(true);
+
+            Object value = sourceField.get(source);
+            targetField.set(target, value);
+        }
+
+        return target;
+    }
+
+}

+ 1 - 1
ruoyi-system/src/main/resources/mapper/system/DoumuProductHistoryMapper.xml

@@ -39,7 +39,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 
     <sql id="selectDoumuProductHistoryVo">
         select history_id,order_number,openid, product_id, name, delivery_type, phonenumber,quantity,province_id,province,city_id,city,county_id,county,lon,lat,
-               status, address, flow_type,,goods_name,total_price, mail_no, create_by, create_time, update_by, update_time, remark from doumu_product_history
+               status, address, flow_type,goods_name,total_price, mail_no, create_by, create_time, update_by, update_time, remark from doumu_product_history
     </sql>
 
     <select id="selectDoumuProductHistoryList" parameterType="DoumuProductHistory" resultMap="DoumuProductHistoryResult">

+ 0 - 1
ruoyi-system/src/main/resources/mapper/system/DoumuProductInfoMapper.xml

@@ -5,7 +5,6 @@
 <mapper namespace="com.ruoyi.system.mapper.DoumuProductInfoMapper">
 
     <resultMap type="DoumuProductInfo" id="DoumuProductInfoResult">
-        <result property="productId"    column="product_id"    />
         <result property="productId"    column="product_id"    />
         <result property="openid"    column="openid"    />
         <result property="orderNumber"    column="order_number"    />