|
@@ -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());
|