YL2767 преди 2 седмици
родител
ревизия
8c8131bea3

+ 2
- 1
src/main/java/com/th/demo/controller/ware/ChangeController.java Целия файл

@@ -24,12 +24,13 @@ public class ChangeController {
24 24
     @RequestMapping(value = "/changeCustomer.do", method = RequestMethod.POST)
25 25
     public String changeCustomer(String json,
26 26
                           String customer,
27
+                          String fkcustomer,
27 28
                           String address,
28 29
                           HttpServletRequest request) {
29 30
         try {
30 31
             String userId = (String) request.getAttribute("userId");
31 32
             String belongId = (String) request.getAttribute("belongId");
32
-            result = changeService.changeCustomer(json,  customer,      address,userId,belongId);
33
+            result = changeService.changeCustomer(json,  customer, fkcustomer, address,userId,belongId);
33 34
         } catch (Exception ex) {
34 35
             ex.printStackTrace();
35 36
             result = JSONTools.toString(ResponseCodeMsg.CODE_EX, ex.getMessage());

+ 27
- 13
src/main/java/com/th/demo/service/impl/ware/ChangeServiceImpl.java Целия файл

@@ -24,6 +24,7 @@ import com.th.demo.tools.Tools;
24 24
 import org.springframework.beans.factory.annotation.Autowired;
25 25
 import org.springframework.stereotype.Service;
26 26
 import org.springframework.transaction.annotation.Transactional;
27
+import org.w3c.css.sac.ElementSelector;
27 28
 
28 29
 import java.util.Collections;
29 30
 import java.util.Date;
@@ -48,38 +49,51 @@ public class ChangeServiceImpl implements ChangeService {
48 49
 
49 50
     @Transactional(rollbackFor = Exception.class)
50 51
     @Override
51
-    public String changeCustomer(String json, String customer,String address,String userId, String belongId) throws Exception{
52
+    public String changeCustomer(String json, String customer,String fkcustomer,String address,String userId, String belongId) throws Exception{
52 53
         List<Store> list = JSON.parseObject(json, new TypeReference<List<Store>>() {
53 54
         });
54 55
         Customer c1 = JSON.parseObject(customer, new TypeReference<Customer>() {
55 56
         });
56
-        Customer c = customerMapper.selectByPrimaryKey(c1.getId());
57
+        Customer fk1 = JSON.parseObject(fkcustomer, new TypeReference<Customer>() {
58
+        });
59
+        Customer cNew = customerMapper.selectByPrimaryKey(c1.getId());
60
+        Customer fkNew = customerMapper.selectByPrimaryKey(fk1.getId());
57 61
         String recordType = "";
58 62
         for (int i = 0; i < list.size(); i++) {
59
-            if(list.get(i).getCustomer().getName().equals(c.getName())){
63
+            if(list.get(i).getCustomer().getName().equals(cNew.getName())){
60 64
                 recordType = "0";
61 65
             }else {
62 66
                 recordType = "1";
63 67
                 AccountDetail accountDetail = getAccountDetail(list.get(i),  userId, belongId);
64 68
                 num += accountDetailMapper.insert(accountDetail);
65 69
             }
66
-            Customer customer1 = customerMapper.selectByPrimaryKey(list.get(i).getFkComponyId());
67
-            ChangeRecord changeRecord = getChangeRecord(recordType, list.get(i), c, customer1, address, userId, belongId);
70
+            Customer fkCustOld = customerMapper.selectByPrimaryKey(list.get(i).getFkComponyId());
71
+            ChangeRecord changeRecord = getChangeRecord(recordType, list.get(i), cNew,fkNew, fkCustOld, address, userId, belongId);
68 72
             num += changeRecordMapper.insert(changeRecord);
69 73
 
70 74
 
71 75
 //            list.get(i).setFkComponyId(list.get(i).getCustomer().getId());
72 76
 //            list.get(i).setCustomer(c);
73
-            list.get(i).setFkComponyId(c.getId());
74
-            list.get(i).setCustomer(list.get(i).getCustomer());
75
-            list.get(i).setReceiveAddress(address);
77
+            list.get(i).setFkComponyId(fkNew.getId());
78
+            list.get(i).setCustomer(cNew);
79
+            if (address != null && !address.equals("")){
80
+                if (address.equals("0")) {
81
+                    list.get(i).setReceiveAddress("");
82
+                }else {
83
+                    list.get(i).setReceiveAddress(address);
84
+                }
85
+            }
76 86
             list.get(i).setChangeCount(list.get(i).getChangeCount()+1);
77 87
             num += storeMapper.updateFKByPKey(list.get(i));
78 88
         }
79 89
         return Tools.moreThanZeroResultJSON(num);
80 90
     }
81 91
 
82
-    private ChangeRecord getChangeRecord(String recordType, Store store, Customer customer, Customer customer1, String receiveAddress, String userId, String belongId) {
92
+    private ChangeRecord getChangeRecord(String recordType, Store store,
93
+                                         Customer newCust,
94
+                                         Customer newFkCust,
95
+                                         Customer oldFkCust,
96
+                                         String receiveAddress, String userId, String belongId) {
83 97
 
84 98
         ChangeRecord record = new ChangeRecord();
85 99
         record.setRecordType(recordType);
@@ -89,15 +103,15 @@ public class ChangeServiceImpl implements ChangeService {
89 103
         record.setMaterialName(store.getMaterial().getName());
90 104
         record.setStandard(store.getMaterial().getStandard());
91 105
         record.setModel(store.getModel());
92
-        if(customer==null) {
106
+        if(newCust==null) {
93 107
             record.setCustomerNameNew("");
94 108
         }else {
95
-            record.setCustomerNameNew(customer.getName());
109
+            record.setCustomerNameNew(newCust.getName());
96 110
         }
97 111
         record.setCustomerNameOld(store.getCustomer().getName());
98 112
 
99
-        record.setFkCustomerNameNew(store.getCustomer().getName());
100
-        record.setFkCustomerNameOld(customer1.getName());
113
+        record.setFkCustomerNameNew(newFkCust.getName());
114
+        record.setFkCustomerNameOld(oldFkCust.getName());
101 115
 
102 116
         record.setCount(store.getCount());
103 117
         record.setWeight(store.getWeight());

+ 31
- 8
src/main/java/com/th/demo/service/impl/ware/DistributionServiceImpl.java Целия файл

@@ -56,6 +56,17 @@ public class DistributionServiceImpl implements DistributionService {
56 56
         });
57 57
         List<Store> list = JSON.parseObject(jsonList, new TypeReference<List<Store>>() {
58 58
         });
59
+        for (int i = 0 ; i < list.size();i++){
60
+            // 不同的客户没法配在一起
61
+            if (!list.get(0).getCustomer().getId().equals(list.get(i).getCustomer().getId())){
62
+                return JSONTools.toString(1,"不同的客户名称的禁止配在同一车上");
63
+            }
64
+            // 不同的货权单位没法配在一起
65
+            if (!list.get(0).getFkComponyId().equals(list.get(i).getFkComponyId())){
66
+                return JSONTools.toString(1,"不同的货权单位的禁止配在同一车上");
67
+            }
68
+        }
69
+
59 70
         Distribution isExist = distributionMapper.selectByTruckNo(distribution.getTruckNo(), belongId);
60 71
         if (isExist == null) {
61 72
             distribution.setAddId(userId);
@@ -82,12 +93,15 @@ public class DistributionServiceImpl implements DistributionService {
82 93
 
83 94
         double cancelWeight = 0;
84 95
         double cancelNum = 0;
96
+        Store store = new Store();
85 97
 
86 98
         for (int i = 0; i < list.size(); i++) {
87 99
             cancelWeight+=list.get(i).getWeight();
88 100
             cancelNum+=list.get(i).getCount();
89
-            list.get(i).setLockFlag("0");
90
-            num += storeMapper.updateByPrimaryKey(list.get(i));
101
+            // list.get(i).setLockFlag("0");
102
+            store = storeMapper.selectByPrimaryKey(list.get(i).getId());
103
+            store.setLockFlag("0");
104
+            num += storeMapper.updateByPrimaryKey(store);
91 105
         }
92 106
         if (distribution.getListDetail().size() == list.size()) {
93 107
             distribution.setOutFlag("2");
@@ -117,13 +131,22 @@ public class DistributionServiceImpl implements DistributionService {
117 131
     }
118 132
 
119 133
 public void lockAndInsertDetail(  List<Store> list,  Distribution distribution , String userId, String belongId){
134
+    Distribution distribution1 = distributionMapper.selectByTruckNo(distribution.getTruckNo(), belongId);
120 135
     for (int i = 0; i < list.size(); i++) {
121
-        list.get(i).setLockFlag("1");
122
-        num += storeMapper.updateByPrimaryKey(list.get(i));
123
-        DistributionDetail detail = getDistributionDetail(distribution, list.get(i), userId, belongId);
124
-        num += distributionDetailMapper.insert(detail);
125
-        DistributionRecord record  = getDistributionRecord(distribution, list.get(i), "1",userId, belongId);
126
-        num += distributionRecordMapper.insert(record);
136
+        Store store = storeMapper.selectByPrimaryKey(list.get(i).getId());
137
+        // 存在赋值为空的情况,追加一次赋值
138
+        // 2025.4.20 数据库增加默认为0的修改临时解决,此处其他项目中要注意
139
+        if (store.getLockFlag() == null || store.getLockFlag() == ""){
140
+            store.setLockFlag("0");
141
+        }
142
+        if (!store.getLockFlag().equals("1") && distribution1.getId() != null && distribution1.getId() != ""){
143
+            list.get(i).setLockFlag("1");
144
+            num += storeMapper.updateByPrimaryKey(list.get(i));
145
+            DistributionDetail detail = getDistributionDetail(distribution1, list.get(i), userId, belongId);
146
+            num += distributionDetailMapper.insert(detail);
147
+            DistributionRecord record  = getDistributionRecord(distribution1, list.get(i), "1",userId, belongId);
148
+            num += distributionRecordMapper.insert(record);
149
+        }
127 150
     }
128 151
 }
129 152
     public DistributionDetail getDistributionDetail(Distribution distribution, Store store, String userId, String belongId) {

+ 16
- 12
src/main/java/com/th/demo/service/impl/ware/OutServiceImpl.java Целия файл

@@ -7,6 +7,7 @@ import com.th.demo.mapping.finance.AccountDetailMapper;
7 7
 import com.th.demo.mapping.maint.*;
8 8
 import com.th.demo.mapping.ware.*;
9 9
 import com.th.demo.model.finance.AccountDetail;
10
+import com.th.demo.model.maint.Customer;
10 11
 import com.th.demo.model.maint.Price;
11 12
 import com.th.demo.model.maint.Stack;
12 13
 import com.th.demo.model.maint.Ware;
@@ -159,7 +160,8 @@ public class OutServiceImpl implements OutService {
159 160
                 List<Store> listStore = storeMapper.selectByWareIdStackIdInStoreId(mapParam);
160 161
                 if (stack.getIsLayer().equals("0") || stack.getIsLayer().equals("2")) {
161 162
                     for (int i = 0; i < listStore.size(); i++) {
162
-                        OutRecord outRecord = getOutRecord(listStore.get(i), distribution.getId(), "1", userId);
163
+                        Store store = storeMapper.selectByPrimaryKey(listStore.get(i).getId());
164
+                        OutRecord outRecord = getOutRecord(store, distribution.getId(), "1", userId);
163 165
                         num += outRecordMapper.insert(outRecord);
164 166
                         AccountDetail accountDetail = getAccountDetail(listStore.get(i), distribution.getSumWeight(), distribution.getSuttle(), userId, belongId);
165 167
                         num += accountDetailMapper.insert(accountDetail);
@@ -174,7 +176,8 @@ public class OutServiceImpl implements OutService {
174 176
                     int min = listStore.get(0).getLayer();
175 177
                     int max = listStore.get(listStore.size() - 1).getLayer();
176 178
                     for (int i = 0; i < listStore.size(); i++) {
177
-                        OutRecord outRecord = getOutRecord(listStore.get(i), distribution.getId(), "1", userId);
179
+                        Store store = storeMapper.selectByPrimaryKey(listStore.get(i).getId());
180
+                        OutRecord outRecord = getOutRecord(store, distribution.getId(), "1", userId);
178 181
                         num += outRecordMapper.insert(outRecord);
179 182
 
180 183
                         AccountDetail accountDetail = getAccountDetail(listStore.get(i), distribution.getSumWeight(), distribution.getSuttle(), userId, belongId);
@@ -232,16 +235,16 @@ public class OutServiceImpl implements OutService {
232 235
         accountDetail.setAddTime(new Date());
233 236
         accountDetail.setCancelFlag("0");
234 237
         accountDetail.setBelongId(belongId);
235
-        if (suttle == 0) {
236
-            plateSuttle = 0.0;
237
-            //storagePrice = price.getStoragePrice() * store.getWeight();
238
-            weightPrice = 0.0;
239
-        } else {
240
-            plateSuttle = suttle / sumWeight * store.getWeight();
241
-            //storagePrice = price.getStoragePrice() * plateSuttle;
242
-           // weightPrice = price.getWeightPrice() * plateSuttle;
243
-        }
244
-        accountDetail.setSuttle(plateSuttle);
238
+//        if (suttle == 0) {
239
+//            plateSuttle = 0.0;
240
+//            //storagePrice = price.getStoragePrice() * store.getWeight();
241
+//            weightPrice = 0.0;
242
+//        } else {
243
+//            plateSuttle = suttle / sumWeight * store.getWeight();
244
+//            //storagePrice = price.getStoragePrice() * plateSuttle;
245
+//           // weightPrice = price.getWeightPrice() * plateSuttle;
246
+//        }
247
+//        accountDetail.setSuttle(plateSuttle);
245 248
 
246 249
         accountDetail.setStoragePrice(storagePrice);
247 250
         accountDetail.setWeightPrice(weightPrice);
@@ -264,6 +267,7 @@ public class OutServiceImpl implements OutService {
264 267
         outRecord.setStandard(store.getMaterial().getStandard());
265 268
         outRecord.setModel(store.getModel());
266 269
         outRecord.setCustomerName(store.getCustomer().getName());
270
+        outRecord.setFkComponyName(store.getFkComponyId());
267 271
         if (recordType.equals("0")) {
268 272
             outRecord.setCount(-1 * store.getCount());
269 273
             outRecord.setWeight(-1 * store.getWeight());

+ 1
- 1
src/main/java/com/th/demo/service/ware/ChangeService.java Целия файл

@@ -1,6 +1,6 @@
1 1
 package com.th.demo.service.ware;
2 2
 
3 3
 public interface ChangeService {
4
-    String changeCustomer(String json, String customer,    String address, String userId, String belongId) throws Exception;
4
+    String changeCustomer(String json, String customer, String fkcustomer,   String address, String userId, String belongId) throws Exception;
5 5
 
6 6
 }

+ 1
- 1
src/main/resource/mapper/ware/DistributionMapper.xml Целия файл

@@ -57,7 +57,7 @@
57 57
       belong_id ,delivery_company)
58 58
     values (#{id,jdbcType=VARCHAR}, #{truckNo,jdbcType=VARCHAR}, #{driverName,jdbcType=VARCHAR},
59 59
       #{driverPhone,jdbcType=VARCHAR}, #{sumWeight,jdbcType=DOUBLE}, #{sumCount,jdbcType=DOUBLE}, 
60
-      #{suttle,jdbcType=DOUBLE}, #{outFlag,jdbcType=VARCHAR}, #{addId,jdbcType=VARCHAR}, 
60
+      0, #{outFlag,jdbcType=VARCHAR}, #{addId,jdbcType=VARCHAR},
61 61
       #{addTime,jdbcType=TIMESTAMP}, #{modifyId,jdbcType=VARCHAR}, #{modifyTime,jdbcType=TIMESTAMP}, 
62 62
       #{cancelId,jdbcType=VARCHAR}, #{cancelTime,jdbcType=TIMESTAMP}, #{cancelFlag,jdbcType=VARCHAR}, 
63 63
       #{belongId,jdbcType=VARCHAR},#{deliveryCompany,jdbcType=VARCHAR})

+ 3
- 3
src/main/resource/mapper/ware/OutRecordMapper.xml Целия файл

@@ -125,7 +125,7 @@
125 125
       modify_id, modify_time, cancel_id, 
126 126
       cancel_time, cancel_flag, belong_id, 
127 127
       plate_no,in_id, record_type,back_flag,receive_address,distribution_id
128
-    ,wgt_dcn_mtc_cd,edge_ty,production_place,tally_people,invoice_price,pack_no,contract_no,ord_no)
128
+    ,wgt_dcn_mtc_cd,edge_ty,production_place,tally_people,invoice_price,pack_no,contract_no,ord_no,fk_compony_name)
129 129
     values (#{id,jdbcType=VARCHAR}, #{wareName,jdbcType=VARCHAR}, #{stackName,jdbcType=VARCHAR}, 
130 130
       #{layer,jdbcType=INTEGER}, #{materialName,jdbcType=VARCHAR}, #{materialNo,jdbcType=VARCHAR}, 
131 131
       #{standard,jdbcType=VARCHAR}, #{model,jdbcType=VARCHAR}, #{customerName,jdbcType=VARCHAR}, 
@@ -136,7 +136,7 @@
136 136
     #{plateNo,jdbcType=VARCHAR},  #{inId,jdbcType=VARCHAR}, #{recordType,jdbcType=VARCHAR},
137 137
     #{backFlag,jdbcType=VARCHAR}, #{receiveAddress,jdbcType=VARCHAR}, #{distributionId,jdbcType=VARCHAR}
138 138
     ,#{wgtDcnMtcCd,jdbcType=VARCHAR},#{edgeTy,jdbcType=VARCHAR},#{productionPlace,jdbcType=VARCHAR},#{tallyPeople,jdbcType=VARCHAR},#{invoicePrice,jdbcType=DOUBLE},
139
-    #{packNo,jdbcType=VARCHAR},#{contractNo,jdbcType=VARCHAR},#{ordNo,jdbcType=VARCHAR})
139
+    #{packNo,jdbcType=VARCHAR},#{contractNo,jdbcType=VARCHAR},#{ordNo,jdbcType=VARCHAR},#{fkComponyName,jdbcType=VARCHAR})
140 140
   </insert>
141 141
   <insert id="insertSelective" parameterType="com.th.demo.model.ware.OutRecord" >
142 142
     insert into t_ware_out_record
@@ -484,8 +484,8 @@
484 484
     ,(select tt.user_desc as in_user from sys_user tt where tt.id = d.add_id) as in_user,d.car_no as in_car_no
485 485
     ,t.invoice_price,t.distribution_id
486 486
     from t_ware_out_record t LEFT JOIN sys_user f on t.add_id = f.id
487
+    LEFT JOIN t_maint_customer e on t.fk_compony_name = e.id
487 488
     ,t_ware_distribution p,t_ware_in_record d
488
-    LEFT JOIN t_maint_customer e on d.fk_compony_name = e.id
489 489
 
490 490
     where t.ware_name  like concat('%',#{param1,jdbcType=VARCHAR},'%')
491 491
     and t.stack_name like concat('%',#{param2,jdbcType=VARCHAR},'%')

+ 2
- 1
src/main/resource/mapper/ware/StoreMapper.xml Целия файл

@@ -86,7 +86,7 @@
86 86
 
87 87
   <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String" >
88 88
     select 
89
-    <include refid="Base_Column_List" />
89
+    *
90 90
     from t_ware_store
91 91
     where id = #{id,jdbcType=VARCHAR}
92 92
   </select>
@@ -381,6 +381,7 @@
381 381
     update t_ware_store
382 382
     set customer_id = #{customer.id,jdbcType=VARCHAR},
383 383
         fk_compony_id = #{fkComponyId,jdbcType=VARCHAR},
384
+        receive_address = #{receiveAddress,jdbcType=VARCHAR},
384 385
         change_count = #{changeCount,jdbcType=DOUBLE}
385 386
     where id = #{id,jdbcType=VARCHAR}
386 387
   </update>

Loading…
Отказ
Запис