add:矿用功能开发

This commit is contained in:
zhangzq
2024-11-07 17:45:06 +08:00
parent e9a84b3268
commit a6faaa1487
4 changed files with 197 additions and 9 deletions

View File

@@ -66,6 +66,13 @@ public class PdaBucketController {
return new ResponseEntity<>(bucketService.confirmGroupBucket(whereJson), HttpStatus.OK);
}
@PostMapping("/confirmGroupBucketAndBag")
@Log("确定组桶及组袋")
@ApiOperation("确定组桶及组袋")
public ResponseEntity<Object> confirmGroupBucketAndBag( @RequestBody Map whereJson) {
return new ResponseEntity<>(bucketService.confirmGroupBucketAndBag(whereJson), HttpStatus.OK);
}
@PostMapping("/print")
@Log("打印")
@ApiOperation("打印")
@@ -103,8 +110,8 @@ public class PdaBucketController {
@PostMapping("/confirmGroupBucket2")
@Log("确定组桶")
@ApiOperation("确定组桶")
@Log("确定无袋组桶")
@ApiOperation("确定无袋组桶")
public ResponseEntity<Object> confirmGroupBucket2( @RequestBody Map whereJson) {
return new ResponseEntity<>(bucketNoBagService.confirmGroupBucket(whereJson), HttpStatus.OK);
}

View File

@@ -36,6 +36,14 @@ public interface PdaBucketService {
* @return Map<String, Object>
*/
Map<String, Object> confirmGroupBucket(Map jsonObject);
/**
* 确定组桶并组袋
*
* @param jsonObject 条件
* @return Map<String, Object>
*/
Map<String, Object> confirmGroupBucketAndBag(Map jsonObject);
/**
* 打印
*

View File

@@ -12,6 +12,7 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.nl.exception.BadRequestException;
import org.nl.modules.system.service.UserService;
import org.nl.modules.system.service.dto.UserDto;
@@ -124,6 +125,169 @@ public class PdaBucketServiceImpl implements PdaBucketService {
return returnjo;
}
@Override
@Transactional(rollbackFor = Exception.class)
public Map<String, Object> confirmGroupBucketAndBag(Map jsonObject) {
JSONObject returnjo = new JSONObject();
//桶记录表
WQLObject bucketRecordTable = WQLObject.getWQLObject("md_pb_bucketrecord");
WQLObject bagRecordTable = WQLObject.getWQLObject("md_pb_bagrecord");
WQLObject bucketChangeTable = WQLObject.getWQLObject("MD_PB_BucketChangeFlow");
//
BigDecimal change_qty = new BigDecimal(0);
BigDecimal result_qty = new BigDecimal(0);
JSONObject mst = JSONObject.parseObject(JSON.toJSONString(jsonObject)).getJSONObject("mst");
JSONArray dtl = JSONObject.parseObject(JSON.toJSONString(jsonObject)).getJSONArray("dtl");
result_qty = BigDecimal.valueOf(mst.getDoubleValue("storage_qty"));
String bucketunique = mst.getString("bucketunique");
String is_active = mst.getString("is_active");
String material_id = mst.getString("material_id");
if (StringUtils.isEmpty(material_id)){
material_id=dtl.getJSONObject(0).getString("material_id");
}
MaterialbaseDto materDto = materialbaseService.findById(Long.parseLong(material_id));
String input_optid = mst.getString("accountId");
Long currentUserId = SecurityUtils.getCurrentUserId();
UserDto userDto = userService.findById(currentUserId);
String input_optname = mst.getString("user");
String pcsn = mst.getString("pcsn");
String ivt_level = mst.getString("ivt_level");
if (StrUtil.isEmpty(material_id)) {
throw new PdaRequestException("物料标识不能为空!");
}
//2.假如桶码没有就插入,有就更新 桶记录表
JSONObject bucketJo = null;
if (StringUtils.isNotEmpty(bucketunique)){
bucketJo = bucketRecordTable.query("bucketunique='" + bucketunique + "'").uniqueResult(0);
}
if (bucketJo !=null) {
// 校验此桶是否有未完成的单据
JSONObject map = new JSONObject();
map.put("flag", "16");
map.put("bucketunique", bucketunique);
JSONArray iosList = WQL.getWO("QPADSTSETSERVICE").addParamMap(map).process().getResultJSONArray(0);
if (ObjectUtil.isNotEmpty(iosList)) {
boolean is_emp = iosList.stream()
.map(row -> (JSONObject) row)
.allMatch(row -> row.getString("is_active").equals(is_active));
if (!is_emp) throw new PdaRequestException("此桶库存是否可用与选择是否可用不一致"+bucketunique+"!");
}
String before_storage_qty = bucketJo.getString("storage_qty");
bucketJo.put("storagevehicle_type", "04");
bucketJo.put("material_id", material_id);
bucketJo.put("pcsn", pcsn);
bucketJo.put("qty_unit_id", materDto.getBase_unit_id());
bucketJo.put("qty_unit_name", materDto.getBase_unit_name());
bucketJo.put("ivt_level", ivt_level);
bucketJo.put("quality_scode", "02");
bucketJo.put("storage_qty", mst.getString("storage_qty"));
bucketJo.put("is_active", is_active);
bucketJo.put("bag_qty", dtl.size());
bucketJo.put("record_order", "1");
bucketJo.put("status", "01");
bucketJo.put("create_id", userDto.getId());
bucketJo.put("create_name", userDto.getNickName());
bucketJo.put("create_time", DateUtil.now());
//变更数量 等于现在的数量减去总数量
change_qty = NumberUtil.sub( mst.getString("storage_qty"),before_storage_qty);
bucketRecordTable.update(bucketJo);
} else {
bucketJo= new JSONObject();
bucketJo.put("bucket_record_id", IdUtil.getSnowflake(1, 1).nextId());
bucketJo.put("bucketunique", bucketunique);
bucketJo.put("storagevehicle_type", "04");
bucketJo.put("material_id", material_id);
bucketJo.put("pcsn", pcsn);
bucketJo.put("qty_unit_id", materDto.getBase_unit_id());
bucketJo.put("qty_unit_name",materDto.getBase_unit_name());
bucketJo.put("ivt_level", ivt_level);
bucketJo.put("quality_scode", "02");
bucketJo.put("storage_qty", mst.getString("storage_qty"));
bucketJo.put("is_active", is_active);
bucketJo.put("bag_qty", dtl.size());
bucketJo.put("record_order", "1");
bucketJo.put("status", "01");
bucketJo.put("print_times", "1");
bucketJo.put("create_id", userDto.getId());
bucketJo.put("create_name", userDto.getNickName());
bucketJo.put("create_time", DateUtil.now());
bucketJo.put("print_type", "04");
bucketJo.put("print_times", "1");
//插入变更数量就是总数
change_qty = NumberUtil.add(change_qty, BigDecimal.valueOf(mst.getDoubleValue("storage_qty")));
bucketRecordTable.insert(bucketJo);
}
//3.更新袋记录表 将之前该桶的袋记录的桶号删除2将新的袋更新
for (int i = 0; i < dtl.size(); i++) {
String bag_id = dtl.getJSONObject(i).getString("bag_id");
if (StrUtil.isEmpty(bag_id)) {
throw new BadRequestException("袋码不能为空!");
}
JSONObject bagObj = bagRecordTable.query("bag_id='" + bag_id + "'").uniqueResult(0);
if (bagObj==null || bagObj.isEmpty()) {
bagObj = dtl.getJSONObject(i);
bagObj.put("bagrecord_id",IdUtil.getSnowflake(1, 1).nextId());
bagObj.put("status", "02");
bagObj.put("bucketunique", bucketunique);
bagObj.put("input_optid", userDto.getId());
bagObj.put("input_optname", userDto.getNickName());
bagObj.put("input_time", DateUtil.now());
bagObj.put("makeup_optid", userDto.getId());
bagObj.put("makeup_optname", userDto.getNickName());
bagObj.put("makeup_time", DateUtil.now());
bagRecordTable.insert(bagObj);
}else {
//假如袋码状态为02 桶码跟新的桶码不一致抛错
String before_status = bagObj.getString("status");
String before_bucketunique = bagObj.getString("bucketunique");
if(StrUtil.equals(before_status,"02")&&(!StrUtil.equals(before_bucketunique,bucketunique))){
throw new PdaRequestException("袋码为【'"+bag_id+"'】已经组过其他桶,不能重复组桶!");
}
bagObj.put("status", "02");
bagObj.put("bucketunique", bucketunique);
bagObj.put("makeup_optid", userDto.getId());
bagObj.put("makeup_optname", userDto.getNickName());
bagObj.put("makeup_time", DateUtil.now());
bagRecordTable.update(bagObj);
}
}
//4、插桶物料变动记录表
JSONObject changeObj = new JSONObject();
changeObj.put("change_id", IdUtil.getSnowflake(1, 1).nextId());
changeObj.put("bucket_code", bucketunique);
changeObj.put("material_id", material_id);
changeObj.put("pcsn", pcsn);
changeObj.put("ivt_level", ivt_level);
changeObj.put("is_active", is_active);
changeObj.put("quality_scode", "02");
String change_type_scode = "";
if (change_qty.doubleValue() < 0) {
change_type_scode = "02";
} else {
change_type_scode = "01";
}
changeObj.put("change_type_scode", change_type_scode);
changeObj.put("change_time", DateUtil.now());
changeObj.put("rec_person", input_optid);
changeObj.put("change_qty", change_qty);
changeObj.put("result_qty", result_qty);
changeObj.put("qty_unit_id", materDto.getBase_unit_id());
changeObj.put("qty_unit_name", materDto.getBase_unit_name());
bucketChangeTable.insert(changeObj);
//查询打印信息
JSONObject result = WQL.getWO("QPADSTSETSERVICE").addParam("flag", "8").addParam("bucketunique", bucketunique).process().uniqueResult(0);
result.put("create_date", DateUtil.now());
returnjo.put("code", "1");
returnjo.put("desc", "组桶成功!");
returnjo.put("result", result);
return returnjo;
}
@Override
@Transactional(rollbackFor = Exception.class)
public Map<String, Object> confirmGroupBucket(Map jsonObject) {
@@ -410,20 +574,25 @@ public class PdaBucketServiceImpl implements PdaBucketService {
if (ObjectUtil.isEmpty(jsonMater)) {
throw new BadRequestException("外部标志【"+ext_id+"】找不到对应物料!");
}
// 判断前端传过来的批次和桶码是否与二维码中的一致
String bucketunique = whereJson.getString("bucketunique");
String pcsn = whereJson.getString("pcsn");
if (ObjectUtil.isNotEmpty(bucketunique) && ObjectUtil.isNotEmpty(pcsn)) {
String material_code = whereJson.getString("material_code");
if (ObjectUtil.isNotEmpty(bucketunique)) {
if (!bucketunique_bag.equals(bucketunique)) {
throw new BadRequestException("当前桶码与二维码桶码不一致,二维码桶码为【"+bucketunique_bag+"");
}
}
if (ObjectUtil.isNotEmpty(pcsn)){
if (!pcsn_bag.equals(pcsn)) {
throw new BadRequestException("当前批次与二维码批次不一致,二维码批次为【"+pcsn_bag+"");
}
}
if ( ObjectUtil.isNotEmpty(material_code)) {
if (!jsonMater.getString("material_code").equals(material_code)) {
throw new BadRequestException("当前物料与二维码物料不一致,二维码物料为【"+material_code+"");
}
}
// group参数
JSONObject result = new JSONObject();
@@ -433,6 +602,7 @@ public class PdaBucketServiceImpl implements PdaBucketService {
result.put("material_id", jsonMater.getString("material_id"));
result.put("material_code", jsonMater.getString("material_code"));
result.put("material_name", jsonMater.getString("material_name"));
result.put("bucketunique",bucketunique_bag);
// 需赋值参数
JSONObject resultTwo = new JSONObject();
@@ -444,8 +614,11 @@ public class PdaBucketServiceImpl implements PdaBucketService {
JSONObject resultOne = WQL.getWO("QPADSTSETSERVICE")
.addParam("flag", "5").addParam("bucketunique", bucketunique_bag)
.process().uniqueResult(0);
if (ObjectUtil.isEmpty(resultOne)) {
throw new BadRequestException("桶信息不存在【"+bucketunique_bag+"");
if (!ObjectUtil.isEmpty(resultOne)) {
String dbBucketunique = resultOne.getString("bucketunique");
if (!dbBucketunique.equals(bucketunique)){
throw new BadRequestException("当前桶记录的桶码"+dbBucketunique+"与袋标签桶码"+bucketunique+"不一致");
}
}
// 返回参数

View File

@@ -2,7 +2,7 @@ spring:
freemarker:
check-template-location: false
profiles:
active: dev
active: prod
jackson:
time-zone: GMT+8
data: