|
|
|
@ -4,6 +4,7 @@ import cn.hutool.core.util.IdUtil; |
|
|
|
import cn.hutool.log.Log; |
|
|
|
import com.alibaba.fastjson.JSONArray; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.baomidou.mybatisplus.extension.api.R; |
|
|
|
import com.dreamchaser.depository_manage.config.PortConfig; |
|
|
|
import com.dreamchaser.depository_manage.controller.PageController; |
|
|
|
import com.dreamchaser.depository_manage.entity.*; |
|
|
|
@ -234,7 +235,19 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
} else { |
|
|
|
for (int i = 0; i < applicationOutRecordPAll.size(); i++) { |
|
|
|
if (state.equals(applicationOutRecordPAll.get(i).getState())) { |
|
|
|
sum += (double) applicationOutRecordPAll.get(i).getQuantity(); |
|
|
|
for (int j = 0; j < applicationOutRecordPAll.size(); j++) { |
|
|
|
ApplicationOutRecordP applicationOutRecordP = applicationOutRecordPAll.get(j); |
|
|
|
// 获取所有子物料
|
|
|
|
Map<String,Object> map = new HashMap<>(); |
|
|
|
map.put("parentId",applicationOutRecordP.getId()); |
|
|
|
List<ApplicationOutRecordMin> minByCondition = depositoryRecordMapper.findApplicationOutMinByCondition(map); |
|
|
|
for (int k = 0; k < minByCondition.size(); k++) { |
|
|
|
ApplicationOutRecordMin applicationOutRecordMin = minByCondition.get(k); |
|
|
|
Integer mid = applicationOutRecordMin.getMid(); |
|
|
|
Material materialById = materialMapper.findMaterialById(mid); |
|
|
|
sum += (double) materialById.getQuantity(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
@ -414,7 +427,10 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public Integer completeApplicationOutMinRecord(Map<String,Object> param, UserByPort userByPort) { |
|
|
|
public RestResponse completeApplicationOutMinRecord(Map<String,Object> param, UserByPort userByPort) { |
|
|
|
// 最终返回值
|
|
|
|
RestResponse restResponse = new RestResponse(); |
|
|
|
|
|
|
|
Integer id = ObjectFormatUtil.toInteger(param.get("id")); |
|
|
|
|
|
|
|
// 获取要完成的子订单
|
|
|
|
@ -482,9 +498,25 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
|
|
|
|
String redisMinRecordKey = "minRecord:"+id; // 设置redis中子订单键值
|
|
|
|
// 修改redis中本子订单状态
|
|
|
|
redisTemplate.opsForHash().put(redisMinRecordKey,"state","2"); |
|
|
|
// redisTemplate.opsForHash().put(redisMinRecordKey,"state","2");
|
|
|
|
// 修改redis中本子订单完成人
|
|
|
|
redisTemplate.opsForHash().put(redisMinRecordKey,"manager",userByPort.getId().toString()); |
|
|
|
// redisTemplate.opsForHash().put(redisMinRecordKey,"manager",userByPort.getId().toString());
|
|
|
|
|
|
|
|
// 删除已完成的订单
|
|
|
|
redisTemplate.delete(redisMinRecordKey); |
|
|
|
// 获取该用户在redis中的订单记录
|
|
|
|
String key = "user:"+userByPort.getId().toString(); |
|
|
|
// 获取当前用户所有订单
|
|
|
|
String minRecord = (String) redisTemplate.opsForHash().get(key, "minRecord"); |
|
|
|
// 删除用户中当前已完成的订单
|
|
|
|
minRecord = minRecord.replace(redisMinRecordKey+",",""); |
|
|
|
redisTemplate.opsForHash().put(key,"minRecord",minRecord); |
|
|
|
if(minRecord.length() == 2){ |
|
|
|
// []
|
|
|
|
// 如果当前用户已经没有剩余订单,则删除
|
|
|
|
redisTemplate.delete("user:"+userByPort.getId()); |
|
|
|
} |
|
|
|
|
|
|
|
// 获取出库仓库信息
|
|
|
|
Depository depositoryRecordById = depositoryMapper.findDepositoryRecordById(applicationOutMinById.getDepositoryId()); |
|
|
|
// 设置子订单新编码
|
|
|
|
@ -533,6 +565,8 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
map.put("id",record.getId()); |
|
|
|
// 修改状态为完成
|
|
|
|
depositoryRecordMapper.updateApplicationOutRecord(map); |
|
|
|
// 删除redis中本订单
|
|
|
|
redisTemplate.delete("record:"+record.getId()); |
|
|
|
} |
|
|
|
|
|
|
|
// 如果是库存转移订单
|
|
|
|
@ -544,11 +578,16 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
map.put("recordId",record.getId()); // 出库订单编号
|
|
|
|
transferMaterial(map); |
|
|
|
} |
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
restResponse.setStatus(200); |
|
|
|
restResponse.setData(""); |
|
|
|
restResponse.setStatusInfo(new StatusInfo("出库成功","出库成功")); |
|
|
|
} |
|
|
|
return result; |
|
|
|
else{ |
|
|
|
restResponse.setStatus(508); |
|
|
|
restResponse.setData(""); |
|
|
|
restResponse.setStatusInfo(new StatusInfo("出库失败","出库失败,库存不足")); |
|
|
|
} |
|
|
|
return restResponse; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
@ -675,7 +714,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
// 用户当前子订单
|
|
|
|
String userMinRecord = (String) redisTemplate.opsForHash().get("user:" + userIdByDid.get(j), "minRecord"); |
|
|
|
if (userMinRecord == null) { // 如果当前用户没有子订单
|
|
|
|
userRecord.put("minRecord", "[" + minRecordKey + "]"); // 插入一条子订单
|
|
|
|
userRecord.put("minRecord", "[" + minRecordKey+"," + "]"); // 插入一条子订单
|
|
|
|
} else { // 如果当前用户已经有子订单
|
|
|
|
StringBuilder minRecordList = new StringBuilder(userMinRecord); // 转为stringbuilder类型
|
|
|
|
minRecordList.insert(1, minRecordKey + ",");// 将当前子订单插入头部
|
|
|
|
@ -1083,7 +1122,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
Double sum = 0.0; |
|
|
|
for (int i = 0; i < applicationInRecordPAll.size(); i++) { |
|
|
|
double price = applicationInRecordPAll.get(i).getPrice(); |
|
|
|
sum += price / 100; |
|
|
|
sum += price * applicationInRecordPAll.get(i).getQuantity() / 100; |
|
|
|
} |
|
|
|
BigDecimal bg = new BigDecimal(sum); |
|
|
|
sum = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); |
|
|
|
@ -1102,15 +1141,33 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
Double sum = 0.0; |
|
|
|
if (state.isEmpty()) { |
|
|
|
for (int i = 0; i < applicationOutRecordPAll.size(); i++) { |
|
|
|
Double price = applicationOutRecordPAll.get(i).getPrice(); |
|
|
|
sum += (double) (price / 100); |
|
|
|
|
|
|
|
ApplicationOutRecordP applicationOutRecordP = applicationOutRecordPAll.get(i); |
|
|
|
// 获取所有子物料
|
|
|
|
Map<String,Object> map = new HashMap<>(); |
|
|
|
map.put("parentId",applicationOutRecordP.getId()); |
|
|
|
List<ApplicationOutRecordMin> minByCondition = depositoryRecordMapper.findApplicationOutMinByCondition(map); |
|
|
|
for (int k = 0; k < minByCondition.size(); k++) { |
|
|
|
ApplicationOutRecordMin applicationOutRecordMin = minByCondition.get(k); |
|
|
|
Integer mid = applicationOutRecordMin.getMid(); |
|
|
|
Material materialById = materialMapper.findMaterialById(mid); |
|
|
|
sum += ((double) materialById.getPrice() / 100) * applicationOutRecordMin.getQuantity(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
for (int i = 0; i < applicationOutRecordPAll.size(); i++) { |
|
|
|
if (state.equals(applicationOutRecordPAll.get(i).getState())) { |
|
|
|
Double price = applicationOutRecordPAll.get(i).getPrice(); |
|
|
|
sum += (double) (price / 100); |
|
|
|
ApplicationOutRecordP applicationOutRecordP = applicationOutRecordPAll.get(i); |
|
|
|
// 获取所有子物料
|
|
|
|
Map<String,Object> map = new HashMap<>(); |
|
|
|
map.put("parentId",applicationOutRecordP.getId()); |
|
|
|
List<ApplicationOutRecordMin> minByCondition = depositoryRecordMapper.findApplicationOutMinByCondition(map); |
|
|
|
for (int k = 0; k < minByCondition.size(); k++) { |
|
|
|
ApplicationOutRecordMin applicationOutRecordMin = minByCondition.get(k); |
|
|
|
Integer mid = applicationOutRecordMin.getMid(); |
|
|
|
Material materialById = materialMapper.findMaterialById(mid); |
|
|
|
sum += ((double) materialById.getPrice() / 100) * applicationOutRecordMin.getQuantity(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
@ -1162,6 +1219,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
return depositoryRecordMapper.findApplicationInRecordByDate(map); |
|
|
|
} else { |
|
|
|
map.put("state", "已出库"); |
|
|
|
|
|
|
|
return depositoryRecordMapper.findApplicationOutRecordByDate(map); |
|
|
|
} |
|
|
|
} |
|
|
|
|