计划模块(优化)

highway
wws 1 year ago
parent 473f789631
commit 9229c77301

@ -42,6 +42,7 @@ public class ProOrderController extends BaseController {
/**
* Code
*
* @param orderCode
* @return
*/
@ -146,6 +147,7 @@ public class ProOrderController extends BaseController {
/**
* code
*
* @param prodCode
* @return
*/
@ -166,6 +168,7 @@ public class ProOrderController extends BaseController {
/**
* list
*
* @param routeCode
* @return
*/

@ -38,155 +38,156 @@ import com.op.common.core.web.page.TableDataInfo;
@RestController
@RequestMapping("/pro/workorder")
public class ProOrderWorkorderController extends BaseController {
@Autowired
private IProOrderWorkorderService proOrderWorkorderService;
@Autowired
private IProWetMaterialPlanDetailService proWetMaterialPlanDetailService;
@Autowired
private IProOrderWorkorderService proOrderWorkorderService;
@Autowired
private IProWetMaterialPlanDetailService proWetMaterialPlanDetailService;
/**
* code
* @param code
* @return
*/
@GetMapping("/getWorkOrders/{code}")
public AjaxResult getWorkOrders(@PathVariable("code") String code) {
return proOrderWorkorderService.getWorkOrders(code);
}
/**
* code
*
* @param code
* @return
*/
@GetMapping("/getWorkOrders/{code}")
public AjaxResult getWorkOrders(@PathVariable("code") String code) {
return proOrderWorkorderService.getWorkOrders(code);
}
/**
*
*
* @return
*/
@GetMapping("/checkWorkOrder/{id}")
public AjaxResult checkWorkOrder(@PathVariable("id") String id){
return proOrderWorkorderService.checkWorkOrder(id);
}
/**
*
*
* @return
*/
@GetMapping("/checkWorkOrder/{id}")
public AjaxResult checkWorkOrder(@PathVariable("id") String id) {
return proOrderWorkorderService.checkWorkOrder(id);
}
/**
*
*
* @param splitOrderDTO
* @return
*/
@PostMapping("/subChangeWorkOrder")
@RequiresPermissions("mes:pro:workorder:edit")
@Log(title = "修改工单", businessType = BusinessType.UPDATE)
public AjaxResult subChangeWorkOrder(@RequestBody SplitOrderDTO splitOrderDTO){
return proOrderWorkorderService.subChangeWorkOrder(splitOrderDTO);
}
/**
*
*
* @param splitOrderDTO
* @return
*/
@PostMapping("/subChangeWorkOrder")
@RequiresPermissions("mes:pro:workorder:edit")
@Log(title = "修改工单", businessType = BusinessType.UPDATE)
public AjaxResult subChangeWorkOrder(@RequestBody SplitOrderDTO splitOrderDTO) {
return proOrderWorkorderService.subChangeWorkOrder(splitOrderDTO);
}
/**
* list
*
* @param proOrderWorkorder
* @return
*/
@PostMapping("/getWorkBatchList")
public AjaxResult getWorkBatchList(@RequestBody ProOrderWorkorder proOrderWorkorder){
return proOrderWorkorderService.getWorkBatchList(proOrderWorkorder);
}
/**
* list
*
* @param proOrderWorkorder
* @return
*/
@PostMapping("/getWorkBatchList")
public AjaxResult getWorkBatchList(@RequestBody ProOrderWorkorder proOrderWorkorder) {
return proOrderWorkorderService.getWorkBatchList(proOrderWorkorder);
}
/**
*
*
* @param proOrderWorkorder
* @return
*/
@PostMapping("/getOrderAndWorkInfo")
public AjaxResult getOrderAndWorkInfo(@RequestBody ProOrderWorkorder proOrderWorkorder){
return proOrderWorkorderService.getOrderAndWorkInfo(proOrderWorkorder);
}
/**
*
*
* @param proOrderWorkorder
* @return
*/
@PostMapping("/getOrderAndWorkInfo")
public AjaxResult getOrderAndWorkInfo(@RequestBody ProOrderWorkorder proOrderWorkorder) {
return proOrderWorkorderService.getOrderAndWorkInfo(proOrderWorkorder);
}
/**
*
*/
@RequiresPermissions("mes:pro:proworkorder:list")
@GetMapping("/list")
public TableDataInfo list(ProOrderWorkorder proOrderWorkorder) {
startPage();
List<ProOrderWorkorder> list = proOrderWorkorderService.selectProOrderWorkorderList(proOrderWorkorder);
return getDataTable(list);
}
/**
*
*/
@RequiresPermissions("mes:pro:proworkorder:list")
@GetMapping("/list")
public TableDataInfo list(ProOrderWorkorder proOrderWorkorder) {
startPage();
List<ProOrderWorkorder> list = proOrderWorkorderService.selectProOrderWorkorderList(proOrderWorkorder);
return getDataTable(list);
}
/**
*
*/
@RequiresPermissions("mes:pro:workorder:export")
@Log(title = "生产工单", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, ProOrderWorkorder proOrderWorkorder) {
List<ProOrderWorkorder> list = proOrderWorkorderService.selectProOrderWorkorderList(proOrderWorkorder);
ExcelUtil<ProOrderWorkorder> util = new ExcelUtil<ProOrderWorkorder>(ProOrderWorkorder.class);
util.exportExcel(response, list, "生产工单数据");
}
/**
*
*/
@RequiresPermissions("mes:pro:workorder:export")
@Log(title = "生产工单", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, ProOrderWorkorder proOrderWorkorder) {
List<ProOrderWorkorder> list = proOrderWorkorderService.selectProOrderWorkorderList(proOrderWorkorder);
ExcelUtil<ProOrderWorkorder> util = new ExcelUtil<ProOrderWorkorder>(ProOrderWorkorder.class);
util.exportExcel(response, list, "生产工单数据");
}
/**
*
*/
@RequiresPermissions("mes:pro:workorder:query")
@GetMapping(value = "/{workorderId}")
public AjaxResult getInfo(@PathVariable("workorderId") String workorderId) {
return success(proOrderWorkorderService.selectProOrderWorkorderByWorkorderId(workorderId));
}
/**
*
*/
@RequiresPermissions("mes:pro:workorder:query")
@GetMapping(value = "/{workorderId}")
public AjaxResult getInfo(@PathVariable("workorderId") String workorderId) {
return success(proOrderWorkorderService.selectProOrderWorkorderByWorkorderId(workorderId));
}
/**
*
*/
@RequiresPermissions("mes:pro:workorder:add")
@Log(title = "生产工单", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody ProOrderWorkorder proOrderWorkorder) {
return toAjax(proOrderWorkorderService.insertProOrderWorkorder(proOrderWorkorder));
}
/**
*
*/
@RequiresPermissions("mes:pro:workorder:add")
@Log(title = "生产工单", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody ProOrderWorkorder proOrderWorkorder) {
return toAjax(proOrderWorkorderService.insertProOrderWorkorder(proOrderWorkorder));
}
/**
*
*/
@RequiresPermissions("mes:pro:workorder:edit")
@Log(title = "生产工单", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody ProOrderWorkorder proOrderWorkorder) {
return toAjax(proOrderWorkorderService.updateProOrderWorkorder(proOrderWorkorder));
}
/**
*
*/
@RequiresPermissions("mes:pro:workorder:edit")
@Log(title = "生产工单", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody ProOrderWorkorder proOrderWorkorder) {
return toAjax(proOrderWorkorderService.updateProOrderWorkorder(proOrderWorkorder));
}
/**
*
*/
@RequiresPermissions("mes:pro:workorder:remove")
@Log(title = "生产工单", businessType = BusinessType.DELETE)
@DeleteMapping("/{workorderIds}")
public AjaxResult remove(@PathVariable String[] workorderIds) {
//什么时候可以删除工单TODO;没进入生产之前都可以?
/**
*
*/
@RequiresPermissions("mes:pro:workorder:remove")
@Log(title = "生产工单", businessType = BusinessType.DELETE)
@DeleteMapping("/{workorderIds}")
public AjaxResult remove(@PathVariable String[] workorderIds) {
//什么时候可以删除工单TODO;没进入生产之前都可以?
// 根据工单的ids查工单的信息
List<ProOrderWorkorder> proOrderWorkorders = proOrderWorkorderService.selectProOrderWorkorderByWorkIds(workorderIds);
if (ObjectUtils.isEmpty(proOrderWorkorders)){
throw new ServiceException("所查询的工单为空!!");
}
ArrayList<String> strings = new ArrayList<>();
for (ProOrderWorkorder proOrderWorkorder : proOrderWorkorders) {
String status = proOrderWorkorder.getStatus();
if (status.equals("w0")){
strings.add(proOrderWorkorder.getWorkorderId());
} else {
throw new ServiceException("工单已经下发,不能删除!");
}
// 判断是否含有湿料计划 boolean值存在为true不存在为false
if (proWetMaterialPlanDetailService.selectProWetMaterialPlanDetailByWorkId(proOrderWorkorder.getWorkorderId())) {
throw new ServiceException("工单已创建湿料计划,不能删除!");
}
}
String[] orderWorkerIds= strings.toArray(new String[0]);
return toAjax(proOrderWorkorderService.deleteProOrderWorkorderByWorkorderIds(orderWorkerIds));
}
List<ProOrderWorkorder> proOrderWorkorders = proOrderWorkorderService.selectProOrderWorkorderByWorkIds(workorderIds);
if (ObjectUtils.isEmpty(proOrderWorkorders)) {
throw new ServiceException("所查询的工单为空!!");
}
ArrayList<String> strings = new ArrayList<>();
for (ProOrderWorkorder proOrderWorkorder : proOrderWorkorders) {
String status = proOrderWorkorder.getStatus();
if (status.equals("w0")) {
strings.add(proOrderWorkorder.getWorkorderId());
} else {
throw new ServiceException("工单已经下发,不能删除!");
}
// 判断是否含有湿料计划 boolean值存在为true不存在为false
if (proWetMaterialPlanDetailService.selectProWetMaterialPlanDetailByWorkId(proOrderWorkorder.getWorkorderId())) {
throw new ServiceException("工单已创建湿料计划,不能删除!");
}
}
String[] orderWorkerIds = strings.toArray(new String[0]);
return toAjax(proOrderWorkorderService.deleteProOrderWorkorderByWorkorderIds(orderWorkerIds));
}
/**
*
*/
@RequiresPermissions("mes:pro:workorder:edit")
@Log(title = "下发生产工单", businessType = BusinessType.OTHER)
@PostMapping("/downWorkorder/{workorderIds}")
public AjaxResult downWorkorder(@PathVariable String[] workorderIds) {
return toAjax(proOrderWorkorderService.downProOrderWorkorderByWorkorderIds(workorderIds));
}
/**
*
*/
@RequiresPermissions("mes:pro:workorder:edit")
@Log(title = "下发生产工单", businessType = BusinessType.OTHER)
@PostMapping("/downWorkorder/{workorderIds}")
public AjaxResult downWorkorder(@PathVariable String[] workorderIds) {
return toAjax(proOrderWorkorderService.downProOrderWorkorderByWorkorderIds(workorderIds));
}
}

@ -55,6 +55,7 @@ public class ProOrderWorkorderServiceImpl implements IProOrderWorkorderService {
private ProWetMaterialPlanDetailMapper proWetMaterialPlanDetailMapper;
@Autowired
private RemoteSapService remoteSapService;
/**
*
*
@ -81,14 +82,14 @@ public class ProOrderWorkorderServiceImpl implements IProOrderWorkorderService {
String prodLineName = "";
String equipCods = "'";
JSONArray codeArray = JSONArray.parseArray(workorder.getProdLineCode());
for(int c=0;c<codeArray.size();c++){
equipCods += codeArray.getJSONArray(c).getString(1)+"','";
for (int c = 0; c < codeArray.size(); c++) {
equipCods += codeArray.getJSONArray(c).getString(1) + "','";
}
Map<String, CascaderDTO> equipMap = proOrderMapper.getEquipInfoByCodes(equipCods.substring(1));//设备字典
Set<String> keys = equipMap.keySet();
for (String key : keys) {
prodLineName += equipMap.get(key).getLabel()+",";
prodLineName += equipMap.get(key).getLabel() + ",";
}
workorder.setProdLineName(prodLineName);
// // 通过设备code查询出机型名称
@ -135,39 +136,39 @@ public class ProOrderWorkorderServiceImpl implements IProOrderWorkorderService {
@DS("#header.poolName")
@Transactional(rollbackFor = Exception.class)
public int deleteProOrderWorkorderByWorkorderIds(String[] workorderIds) {
for(String workorderId:workorderIds){
for (String workorderId : workorderIds) {
//要删除的工单id们
List<String> delteIds = new ArrayList<>();
delteIds.add(workorderId);
//最底级,用来还原订单拆分数量
List<ProOrderWorkorder> workers = new ArrayList<>();
ProOrderWorkorder work = proOrderWorkorderMapper.selectProOrderWorkorderByWorkorderId(workorderId);
if(work != null){
if (work != null) {
workers.add(work);
ProOrderWorkorder bottomWork = work;
Boolean run = true;
while(run){
while (run) {
//上级
ProOrderWorkorder topworkers = proOrderWorkorderMapper.selectWorkOrderByCode(bottomWork.getParentOrder());
//有上级code
if(topworkers!=null) {
if (topworkers != null) {
workers.add(topworkers);
delteIds.add(topworkers.getWorkorderId());
bottomWork.setParentOrder(topworkers.getParentOrder());
}else{
} else {
run = false;
}
}
}
String[] workorderIds0 = (String[])delteIds.toArray(new String[delteIds.size()]);
if(workorderIds0.length>0){
String[] workorderIds0 = (String[]) delteIds.toArray(new String[delteIds.size()]);
if (workorderIds0.length > 0) {
//删除工单(字母)pro_order_workorder
proOrderWorkorderMapper.deleteProOrderWorkorderByWorkorderIds(workorderIds0);
//删除批次pro_order_workorder_batch
proOrderWorkorderBatchMapper.deleteProOrderWorkorderBatchByWorkorderIds(workorderIds0);
}
if(!CollectionUtils.isEmpty(workers)){
if (!CollectionUtils.isEmpty(workers)) {
//释放订单拆分数pro_order
proOrderMapper.updateOrderBatch(workers);
}
@ -192,6 +193,7 @@ public class ProOrderWorkorderServiceImpl implements IProOrderWorkorderService {
/**
*
* (sap)
*
* @param workorderIds
* @return
*/
@ -201,12 +203,12 @@ public class ProOrderWorkorderServiceImpl implements IProOrderWorkorderService {
public int downProOrderWorkorderByWorkorderIds(String[] workorderIds) {
List<ProOrderWorkorder> workorders = proOrderWorkorderMapper.getWorkOrderByIds(workorderIds);
for(ProOrderWorkorder workorder:workorders){
for (ProOrderWorkorder workorder : workorders) {
//关联工艺
if(StringUtils.isNotBlank(workorder.getRouteCode())){
if (StringUtils.isNotBlank(workorder.getRouteCode())) {
List<ProWorkorderProcessDetail> workDetails = proWorkorderProcessDetailMapper.getWorkOrderDetailsByRouteCode(workorder);
if(!CollectionUtils.isEmpty(workDetails)){
workDetails.forEach(str->{
if (!CollectionUtils.isEmpty(workDetails)) {
workDetails.forEach(str -> {
str.setRecordId(IdUtils.fastSimpleUUID());
str.setWorkorderId(workorder.getWorkorderId());
str.setStatus("s0");//未执行
@ -220,54 +222,54 @@ public class ProOrderWorkorderServiceImpl implements IProOrderWorkorderService {
}
List<SapCreateOrder> sapList = null;//回传给sap的工单
//如果是白坯生成备料单
for(String workorderId:workorderIds){
for (String workorderId : workorderIds) {
ProOrderWorkorder whiteOrder = proOrderWorkorderMapper.selectProOrderWorkorderByWorkorderId(workorderId);
if(whiteOrder!=null&&"white".equals(whiteOrder.getProdType())){//是白坯订单,自主生成领料单;
if (whiteOrder != null && "white".equals(whiteOrder.getProdType())) {//是白坯订单,自主生成领料单;
//备(领)料主单
MesPrepareDTO mesPrepare = new MesPrepareDTO();
BeanUtils.copyBeanProp(mesPrepare,whiteOrder);
mesPrepare.setPrepareId(whiteOrder.getWorkorderCode()+"L");//领料单号
BeanUtils.copyBeanProp(mesPrepare, whiteOrder);
mesPrepare.setPrepareId(whiteOrder.getWorkorderCode() + "L");//领料单号
mesPrepare.setWorkorderCode(whiteOrder.getWorkorderCode());
mesPrepare.setCreateBy(SecurityUtils.getUsername());
mesPrepare.setCreateTime(DateUtils.getNowDate());
mesPrepare.setStatus("L0");//待确认
proOrderWorkorderMapper.createPrepare(mesPrepare);
//备(领)料明细
ProWetMaterialPlanDetail planDetail= proWetMaterialPlanDetailMapper.getWetInfo(workorderId);
ProWetMaterialPlanDetail planDetail = proWetMaterialPlanDetailMapper.getWetInfo(workorderId);
List<MesPrepareDetailDTO> details = new ArrayList<>();
MesPrepareDetailDTO detail = new MesPrepareDetailDTO();
detail.setCreateTime(DateUtils.getNowDate());
detail.setCreateBy(SecurityUtils.getUsername());
detail.setRecordId(IdUtils.fastSimpleUUID());
if(planDetail != null){
if (planDetail != null) {
detail.setMaterailName(planDetail.getMaterialName());
detail.setMaterialCode(planDetail.getMaterialCode());
detail.setProductDate(planDetail.getProductDate());
detail.setShiftId(planDetail.getShiftId()+"");
detail.setShiftId(planDetail.getShiftId() + "");
detail.setProdType("white");
detail.setFactoryCode(planDetail.getFactoryCode());
}
details.add(detail);
proOrderWorkorderMapper.createPrepareDetails(details);
}else if(whiteOrder!=null){//成品的母工单回传sap
} else if (whiteOrder != null) {//成品的母工单回传sap
sapList = new ArrayList<>();
SapCreateOrder sap = new SapCreateOrder();
sap.setWerks(whiteOrder.getFactoryCode());//工厂编码
sap.setAufpar(whiteOrder.getProdType());//订单类型
sap.setMatnr(whiteOrder.getProductCode());//物料编号
sap.setQuantity(whiteOrder.getQuantitySplit()+"");//数量
sap.setDates(DateUtils.parseDateToStr("yyyy-MM-dd",whiteOrder.getProductDate()));//开始时间
sap.setDatee(DateUtils.parseDateToStr("yyyy-MM-dd",whiteOrder.getProductDate()));//完成时间
sap.setQuantity(whiteOrder.getQuantitySplit() + "");//数量
sap.setDates(DateUtils.parseDateToStr("yyyy-MM-dd", whiteOrder.getProductDate()));//开始时间
sap.setDatee(DateUtils.parseDateToStr("yyyy-MM-dd", whiteOrder.getProductDate()));//完成时间
sapList.add(sap);
R<List<String>> r = remoteSapService.SapCreateOrder(sapList);
logger.info("sap工单回传"+r.getMsg());
if(500==r.getCode()){
logger.error("sap工单回传"+r.getMsg());
logger.info("sap工单回传" + r.getMsg());
if (500 == r.getCode()) {
logger.error("sap工单回传" + r.getMsg());
return 0;
}
List<String> returnCodes = r.getData();
if(!CollectionUtils.isEmpty(returnCodes)){
for(String sapCode:returnCodes){
if (!CollectionUtils.isEmpty(returnCodes)) {
for (String sapCode : returnCodes) {
ProOrderWorkorder oworkSap = new ProOrderWorkorder();
oworkSap.setWorkorderCodeSap(sapCode);
oworkSap.setWorkorderId(workorderId);//工单编码
@ -282,7 +284,7 @@ public class ProOrderWorkorderServiceImpl implements IProOrderWorkorderService {
oworkSapParent.setUpdateTime(DateUtils.getNowDate());
proOrderWorkorderMapper.updateWorkOrderCodeSap(oworkSapParent);
logger.info("sap工单回传sap虚拟工单号"+sapCode);
logger.info("sap工单回传sap虚拟工单号" + sapCode);
}
}
@ -294,7 +296,7 @@ public class ProOrderWorkorderServiceImpl implements IProOrderWorkorderService {
return 1;
}
// //获取最低级材料
// //获取最低级材料
// private void getLastChildren(List<BaseBomComponentDTO> all, List<BaseBomComponentDTO> allChildren , BaseBomComponentDTO bc) {
// List<BaseBomComponentDTO> cList = all.stream().filter(item -> item.getCumc().equals(bc.getComponent()))
// .collect(Collectors.toList());
@ -334,10 +336,10 @@ public class ProOrderWorkorderServiceImpl implements IProOrderWorkorderService {
// return bomdtos;
// }
//根据工单子单编码获取最顶级订单的母单
private ProOrder getTopOrder(String workorderId){
private ProOrder getTopOrder(String workorderId) {
//pro_order_workorder
ProOrder topOrder = proOrderWorkorderMapper.getOrderCodeById(workorderId);
while(!"0".equals(topOrder.getParentOrder())&& StringUtils.isNotEmpty(topOrder.getParentOrder())){
while (!"0".equals(topOrder.getParentOrder()) && StringUtils.isNotEmpty(topOrder.getParentOrder())) {
//pro_order_workorder
topOrder = proOrderWorkorderMapper.getOrderCodeById(topOrder.getParentOrder());
}
@ -358,15 +360,15 @@ public class ProOrderWorkorderServiceImpl implements IProOrderWorkorderService {
while (run) {
ProOrderWorkorder fatherWorkOrder = proOrderWorkorderMapper.selectWorkOrderByCode(proOrderWorkorder.getParentOrder());
// 如果存在父工单
if (fatherWorkOrder != null ){
BeanUtils.copyProperties(fatherWorkOrder,proOrderWorkorder);
}else {
if (fatherWorkOrder != null) {
BeanUtils.copyProperties(fatherWorkOrder, proOrderWorkorder);
} else {
run = false;
}
}
// 通过母订单id查询母订单详情
ProOrder proOrder = proOrderMapper.selectProOrderById(proOrderWorkorder.getOrderId());
if(proOrder != null){
if (proOrder != null) {
// 递归查询子订单
recursiveQueryChildOrder(proOrder);
}
@ -374,8 +376,8 @@ public class ProOrderWorkorderServiceImpl implements IProOrderWorkorderService {
formatProOrderWorkorder(proOrderWorkorder);
Map orderAndWork = new HashMap();
orderAndWork.put("order",proOrder);
orderAndWork.put("workOrder",proOrderWorkorder);
orderAndWork.put("order", proOrder);
orderAndWork.put("workOrder", proOrderWorkorder);
return success(orderAndWork);
}
@ -390,12 +392,12 @@ public class ProOrderWorkorderServiceImpl implements IProOrderWorkorderService {
@DS("#header.poolName")
public AjaxResult getWorkBatchList(ProOrderWorkorder proOrderWorkorder) {
boolean run = true;
while (run){
while (run) {
ProOrderWorkorder fatherWorkOrder = proOrderWorkorderMapper.selectWorkOrderByCode(proOrderWorkorder.getParentOrder());
// 如果存在父工单
if (fatherWorkOrder != null){
BeanUtils.copyProperties(fatherWorkOrder,proOrderWorkorder);
}else {
if (fatherWorkOrder != null) {
BeanUtils.copyProperties(fatherWorkOrder, proOrderWorkorder);
} else {
run = false;
}
}
@ -428,19 +430,19 @@ public class ProOrderWorkorderServiceImpl implements IProOrderWorkorderService {
// 用于循环
ProOrderWorkorder childWorkOrder = new ProOrderWorkorder();
BeanUtils.copyProperties(proWorkOrder,childWorkOrder);
BeanUtils.copyProperties(proWorkOrder, childWorkOrder);
while (getworkOrder) {
// 通过parentOrder查询父工单信息
ProOrderWorkorder fatherWorkOrder = proOrderWorkorderMapper.selectWorkOrderByCode(childWorkOrder.getParentOrder());
if (fatherWorkOrder != null){
if (fatherWorkOrder != null) {
// 将重置对象
BeanUtils.copyProperties(fatherWorkOrder,childWorkOrder);
BeanUtils.copyProperties(fatherWorkOrder, childWorkOrder);
// 将工单放入list
workOrderList.add(fatherWorkOrder);
// 将id放入
ids.add(fatherWorkOrder.getWorkorderId());
}else {
} else {
// 终止循环
getworkOrder = false;
}
@ -459,22 +461,22 @@ public class ProOrderWorkorderServiceImpl implements IProOrderWorkorderService {
}
}
//校验各工序设备是否已选择
List<CascaderDTO> processes= proOrderMapper.getRouteProcess(splitOrderDTO.getRouteCode());
if(splitOrderDTO.getProdLineCodeArray().length == 0){
List<CascaderDTO> processes = proOrderMapper.getRouteProcess(splitOrderDTO.getRouteCode());
if (splitOrderDTO.getProdLineCodeArray().length == 0) {
checkout = false;
return error(500, "必须选择工单生产设备!");
}else{
} else {
String codeArray = JSONArray.toJSONString(splitOrderDTO.getProdLineCodeArray());
for(int i=0;i<processes.size();i++){
if(codeArray.indexOf(processes.get(i).getValue())<0){
for (int i = 0; i < processes.size(); i++) {
if (codeArray.indexOf(processes.get(i).getValue()) < 0) {
checkout = false;
return error(500, "所有有工序节点都必须选择生产设备!");
}
}
String[][] array = splitOrderDTO.getProdLineCodeArray();
for(int m=0;m<array.length;m++){
if(array[m].length<2){
for (int m = 0; m < array.length; m++) {
if (array[m].length < 2) {
checkout = false;
return error(500, "工序没有生产设备可选择,请维护工艺!");
}
@ -483,14 +485,14 @@ public class ProOrderWorkorderServiceImpl implements IProOrderWorkorderService {
splitOrderDTO.setProdLineCode(codeArray);
}
if (checkout){
if (checkout) {
// 删除所有工单s下的批次信息
int i = proOrderWorkorderBatchMapper.deleteProOrderWorkorderBatchByWorkorderIds(workorderIds);
// 删除湿料计划
proWetMaterialPlanDetailMapper.deleteProWetMaterialPlanDetailByWorkId(proWorkOrder.getWorkorderId());
// 创建订单信息并将信息copy进去
ProOrder proOrder = new ProOrder();
BeanUtils.copyProperties(splitOrderDTO.getProduct(),proOrder);
BeanUtils.copyProperties(splitOrderDTO.getProduct(), proOrder);
// 设置换算基数,用于获得换算值
Long quantity = proOrder.getQuantity();
// 创建批次表通用对象
@ -505,7 +507,7 @@ public class ProOrderWorkorderServiceImpl implements IProOrderWorkorderService {
// 更新订单
proOrder.setUpdateBy(SecurityContextHolder.getUserName());
proOrder.setUpdateTime(DateUtils.getNowDate());
proOrder.setQuantitySplit(proOrder.getQuantitySplit()+Long.valueOf(proOrder.getAtrr1()));
proOrder.setQuantitySplit(proOrder.getQuantitySplit() + Long.valueOf(proOrder.getAtrr1()));
proOrderMapper.updateProOrder(proOrder);
// 设置工单信息
proOrderWorkorder.setUpdateBy(SecurityContextHolder.getUserName());
@ -513,16 +515,16 @@ public class ProOrderWorkorderServiceImpl implements IProOrderWorkorderService {
// 拆分数量
proOrderWorkorder.setQuantitySplit(Long.valueOf(proOrder.getAtrr1()));
// 2.将工单信息更新至数据库
if (splitOrderDTO.getProdLineCode() != null){
if (splitOrderDTO.getProdLineCode() != null) {
proOrderWorkorder.setProdLineCode(splitOrderDTO.getProdLineCode());
}
if (splitOrderDTO.getProductDate() != null){
if (splitOrderDTO.getProductDate() != null) {
proOrderWorkorder.setProductDate(splitOrderDTO.getProductDate());
}
if (splitOrderDTO.getShiftId() != null){
if (splitOrderDTO.getShiftId() != null) {
proOrderWorkorder.setShiftId(splitOrderDTO.getShiftId());
}
if (splitOrderDTO.getRouteCode() != null){
if (splitOrderDTO.getRouteCode() != null) {
proOrderWorkorder.setRouteCode(splitOrderDTO.getRouteCode());
}
// 白坯工单返修-车数
@ -545,7 +547,7 @@ public class ProOrderWorkorderServiceImpl implements IProOrderWorkorderService {
// 生成批次号
workBatch.setBatchCode(batch.getBatchCode());
// 生成批次数量
workBatch.setBatchQuantity(batch.getBatchQuantity()*conver);
workBatch.setBatchQuantity(batch.getBatchQuantity() * conver);
// 更新至数据库
proOrderWorkorderBatchMapper.insertProOrderWorkorderBatch(workBatch);
@ -555,7 +557,7 @@ public class ProOrderWorkorderServiceImpl implements IProOrderWorkorderService {
}
// 如果存在子节点
if (proOrder.getChildren().size()>0){
if (proOrder.getChildren().size() > 0) {
ProOrderDTO newProOrder = (ProOrderDTO) proOrder.getChildren().get(0);
// 更新换算值
conver = (newProOrder.getQuantity() / quantity);
@ -584,11 +586,8 @@ public class ProOrderWorkorderServiceImpl implements IProOrderWorkorderService {
public AjaxResult checkWorkOrder(String id) {
// 判断工单状态1.活动不可以2.已报工不可以
ProOrderWorkorder proOrderWorkorder = proOrderWorkorderMapper.selectProOrderWorkorderByWorkorderId(id);
if (proOrderWorkorder.getStatus().equals("w2")) {
return error("工单处于活动状态!不可更改!");
}
if (proOrderWorkorder.getStatus().equals("w3")) {
return error("工单处于报工状态!不可更改!");
if (!(proOrderWorkorder.getStatus().equals("w0") ||proOrderWorkorder.getStatus().equals("w1"))) {
return error("工单已生产,不可变更!");
}
return success();
}
@ -596,6 +595,7 @@ public class ProOrderWorkorderServiceImpl implements IProOrderWorkorderService {
/**
* workerIdsProOrderWorkorder
*
* @param workerIds
* @return
*/
@ -607,6 +607,7 @@ public class ProOrderWorkorderServiceImpl implements IProOrderWorkorderService {
/**
* code
*
* @param code
* @return
*/
@ -637,7 +638,7 @@ public class ProOrderWorkorderServiceImpl implements IProOrderWorkorderService {
// 反转list
List<ProOrderWorkorder> reversalWorkOrderList = new ArrayList<>();
for (int i = proOrderWorkorderList.size()-1; i >= 0; i--) {
for (int i = proOrderWorkorderList.size() - 1; i >= 0; i--) {
reversalWorkOrderList.add(proOrderWorkorderList.get(i));
}
@ -655,22 +656,22 @@ public class ProOrderWorkorderServiceImpl implements IProOrderWorkorderService {
JSONArray codeArray = JSONArray.parseArray(proOrderWorkorder.getProdLineCode());
String[][] array = new String[codeArray.size()][2];
for(int c1=0;c1<codeArray.size();c1++){
for(int c2=0;c2<2;c2++){
for (int c1 = 0; c1 < codeArray.size(); c1++) {
for (int c2 = 0; c2 < 2; c2++) {
array[c1][c2] = codeArray.getJSONArray(c1).getString(c2);
}
}
proOrderWorkorder.setProdLineCodeArray(array);
String prodLineName = "";
String equipCods = "'";
for(int c=0;c<codeArray.size();c++){
equipCods += codeArray.getJSONArray(c).getString(1)+"','";
for (int c = 0; c < codeArray.size(); c++) {
equipCods += codeArray.getJSONArray(c).getString(1) + "','";
}
Map<String, CascaderDTO> equipMap = proOrderMapper.getEquipInfoByCodes(equipCods.substring(1));//设备字典
Set<String> keys = equipMap.keySet();
for (String key : keys) {
prodLineName += equipMap.get(key).getLabel()+",";
prodLineName += equipMap.get(key).getLabel() + ",";
}
proOrderWorkorder.setProdLineCode(prodLineName);

@ -64,6 +64,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="planDateStart != null "> and CONVERT(varchar(10),plan_pro_date, 120) >= '${planDateStart}'</if>
<if test="planDateEnd != null "> and '${planDateEnd}%' >= CONVERT(varchar(10),plan_pro_date, 120)</if>
</where>
and prod_type != 'white'
ORDER BY plan_pro_date DESC
</select>

Loading…
Cancel
Save