This commit is contained in:
2022-11-30 12:51:53 +08:00
parent 3bfe8438d1
commit 22ff161288
109 changed files with 4922 additions and 2374 deletions

View File

@@ -80,7 +80,7 @@ public interface WorkProcedureService {
JSONArray downSelect();
/**
* 查询所有数据不分页
* @param whereJson 条件参数
* @param
* @return List<PdmBaseWorkprocedureDto>
*/
List<WorkprocedureDto> queryWorkprocedure();

View File

@@ -17,6 +17,7 @@ import org.nl.utils.SecurityUtils;
import org.nl.wms.basedata.pdm.service.WorkProcedureService;
import org.nl.wms.basedata.pdm.service.dto.WorkProcedureDto;
import org.nl.wms.st.out.service.dto.WorkprocedureDto;
import org.nl.wql.WQL;
import org.nl.wql.core.bean.ResultBean;
import org.nl.wql.core.bean.WQLObject;
import org.nl.wql.util.WqlUtil;
@@ -155,6 +156,7 @@ public class WorkProcedureServiceImpl implements WorkProcedureService {
JSONArray resultJSONArray = workProcedureTab.query("is_delete = '0' and is_used ='1'", "workprocedure_code").getResultJSONArray(0);
return resultJSONArray;
}
@Override
public List<WorkprocedureDto> queryWorkprocedure() {
WQLObject wo = WQLObject.getWQLObject("pdm_bi_workprocedure");

View File

@@ -72,5 +72,13 @@ public class WmsToAcsController {
return new ResponseEntity<>(wmsToAcsService.orderStatusUpdate(arr), HttpStatus.OK);
}
@PostMapping("/replaceDevice")
@Log("更换工单设备")
@ApiOperation("更换工单设备")
public ResponseEntity<Object> replaceDevice(@RequestBody Map whereJson) {
JSONArray arr = JSONArray.parseArray(JSON.toJSONString(whereJson.get("data")));
return new ResponseEntity<>(wmsToAcsService.replaceDevice(arr), HttpStatus.OK);
}
}

View File

@@ -49,4 +49,11 @@ public interface WmsToAcsService {
* @return
*/
Map<String, Object> orderStatusUpdate(JSONArray arr);
/**
* 更换工单设备
* @param arr
* @return
*/
Map<String, Object> replaceDevice(JSONArray arr);
}

View File

@@ -222,8 +222,13 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
String order_code = param.getString("order");
String real_qty = param.getString("real_qty");
WQLObject wo = WQLObject.getWQLObject("mps_bd_produceshiftorder");
JSONObject jsonObject = wo.query("produceorder_code = '" + order_code + "'").uniqueResult(0);
String report_qty = jsonObject.getString("report_qty");
int i = Integer.parseInt(report_qty);
int j = Integer.parseInt(real_qty);
int k = i + j;
JSONObject map = new JSONObject();
map.put("real_qty", real_qty);
map.put("real_qty", k);
wo.update(map, "produceorder_code = '" + order_code + "' and order_status != '04'");
} catch (Exception e){
result.put("status", 400);

View File

@@ -48,4 +48,10 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
return AcsUtil.notifyAcs(api, arr);
}
@Override
public Map<String, Object> replaceDevice(JSONArray arr) {
String api = "api/wms/replaceDevice";
return AcsUtil.notifyAcs(api, arr);
}
}

View File

@@ -0,0 +1,121 @@
package org.nl.wms.ext.bigScreen.service.impl;
import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSONObject;
import org.nl.wms.ext.bigScreen.service.ProductService;
import org.nl.wql.WQL;
import java.text.DecimalFormat;
import java.util.HashMap;
import java.util.Map;
/**
* @author: geng by
* @createDate: 2022/10/24
*/
public class ManualProductServiceImpl implements ProductService {
//今日计划量
private Integer todayWTPlan = 0;
private Integer todayZHPlan = 0;
private Integer todayCPPlan = 0;
//月计划量
private Integer monWTPlan = 0;
private Integer monZHPlan = 0;
private Integer monCPPlan = 0;
//今日完成量
private Integer todayWTFinish = 0;
private Integer todayZHFinish = 0;
private Integer todayCPFinish = 0;
//月完成量
private Integer monWTFinish = 0;
private Integer monZHFinish = 0;
private Integer monCPFinish = 0;
@Override
public Map<String, Object> planReached(Map<String, String> param) {
DecimalFormat df = new DecimalFormat("0.00");
todayWTFinish = todayWTFinish + ((todayWTPlan / 12 / 60 / 60) * 5);
todayZHFinish = todayZHFinish + ((todayZHPlan / 12 / 60 / 60) * 5);
todayCPFinish = todayCPFinish + ((todayCPPlan / 12 / 60 / 60) * 5);
//计算当天的计划达成
//01-弯头工段、02-综合工段、03-成品工段
JSONObject jo1 = new JSONObject();
jo1.put("real_qty",todayWTFinish);
jo1.put("plan_qty",todayWTPlan);
jo1.put("finish_rate",df.format((float)(todayWTFinish / todayWTPlan)));
JSONObject jo2 = new JSONObject();
jo2.put("real_qty",todayZHFinish);
jo2.put("plan_qty",todayZHPlan);
jo2.put("finish_rate",df.format((float)(todayZHFinish / todayZHPlan)));
JSONObject jo3 = new JSONObject();
jo3.put("real_qty",todayCPFinish);
jo3.put("plan_qty",todayCPPlan);
jo3.put("finish_rate",df.format((float)(todayCPFinish / todayCPPlan)));
JSONObject dayResult = new JSONObject();
dayResult.put("jo1", jo1);
dayResult.put("jo2", jo2);
dayResult.put("jo3", jo3);
//计算一个月的计划达成
JSONObject monthResult = new JSONObject();
JSONObject joo1 = new JSONObject();
joo1.put("real_qty",monWTFinish);
joo1.put("plan_qty",monWTPlan);
joo1.put("finish_rate",df.format((float)((monWTFinish + todayWTFinish) / monWTPlan)));
JSONObject joo2 = new JSONObject();
joo2.put("real_qty",monZHFinish);
joo2.put("plan_qty",monZHPlan);
joo2.put("finish_rate",df.format((float)((monZHFinish + todayZHFinish) / monZHPlan)));
JSONObject joo3 = new JSONObject();
joo3.put("real_qty",monCPFinish);
joo3.put("plan_qty",monCPPlan);
joo3.put("finish_rate",df.format((float)((monCPFinish + todayCPFinish) / monCPPlan)));
monthResult.put("joo1", joo1);
monthResult.put("joo2", joo2);
monthResult.put("joo3", joo3);
JSONObject returnjo = new JSONObject();
returnjo.put("code", "1");
returnjo.put("desc", "操作成功!");
returnjo.put("dayResult", dayResult);
returnjo.put("monthResult", monthResult);
return returnjo;
}
@Override
public Map<String, Object> productSchedule(Map<String, String> param) {
return null;
}
@Override
public Map<String, Object> output(Map<String, String> param) {
return null;
}
@Override
public Map<String, Object> worksectionHarvest(Map<String, String> param) {
return null;
}
@Override
public Map<String, Object> topHarvest(Map<String, String> param) {
return null;
}
@Override
public Map<String, Object> monthHarvest(Map<String, String> param) {
return null;
}
@Override
public Map<String, Object> unfinishOrder(Map<String, String> param) {
return null;
}
@Override
public Map<String, Object> monthOrder(Map<String, String> param) {
return null;
}
}

View File

@@ -1,6 +1,8 @@
package org.nl.wms.mps.rest;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@@ -14,7 +16,9 @@ import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;
@@ -154,4 +158,35 @@ public class ProduceshiftorderController {
return new ResponseEntity<>(produceshiftorderService.getDtl(param), HttpStatus.OK);
}
@PostMapping("/excelImport")
@Log("excel导入")
@ApiOperation("excel导入")
public ResponseEntity<Object> excelImport(@RequestParam("file") MultipartFile file, HttpServletRequest request) {
produceshiftorderService.excelImport(file, request);
return new ResponseEntity<>(HttpStatus.OK);
}
@PostMapping("/getNotWorkDeviceByWorkproceduceId")
@Log("根据工序查询没有工单的设备")
@ApiOperation("根据工序查询没有工单的设备")
//@PreAuthorize("@el.check('WorkProcedure:add')")
public ResponseEntity<Object> getNotWorkDeviceByWorkproceduceId(@RequestBody JSONObject param) {
return new ResponseEntity<>(produceshiftorderService.getNotWorkDeviceByWorkproceduceId(param),HttpStatus.CREATED);
}
@PostMapping("/replaceDevice")
@Log("更换工单设备")
@ApiOperation("更换工单设备")
public ResponseEntity<Object> replaceDevice(@RequestBody JSONObject param) {
produceshiftorderService.replaceDevice(param);
return new ResponseEntity<>( HttpStatus.OK);
}
@GetMapping("/getUser")
@Log("查询操作人员")
@ApiOperation("查询操作人员")
public ResponseEntity<Object> getUser() {
return new ResponseEntity<>(produceshiftorderService.getUser(), HttpStatus.OK);
}
}

View File

@@ -4,7 +4,9 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.nl.wms.mps.service.dto.ProduceshiftorderDto;
import org.springframework.data.domain.Pageable;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;
@@ -121,4 +123,26 @@ public interface ProduceshiftorderService {
* @return
*/
JSONArray getDtl(JSONObject param);
/**
* excel工单批量导入
* @param file
* @param request
*/
void excelImport(MultipartFile file, HttpServletRequest request);
/**
* 更换设备时根据工单所属工序 查询所有工单中没有生产的设备
* @param param
* @return
*/
JSONArray getNotWorkDeviceByWorkproceduceId(JSONObject param);
/**
* 更换设备
* @param param
*/
void replaceDevice(JSONObject param);
JSONArray getUser();
}

View File

@@ -103,5 +103,8 @@ public class ProduceshiftorderDto implements Serializable {
private Long device_id;
private Long sale_id;
/** 操作人员 */
private Long jockey_id;
private Integer orderNum;
}

View File

@@ -1,11 +1,15 @@
package org.nl.wms.mps.service.impl;
import cn.hutool.core.date.DateField;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.poi.excel.ExcelReader;
import cn.hutool.poi.excel.ExcelUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
@@ -14,6 +18,7 @@ import lombok.extern.slf4j.Slf4j;
import org.nl.exception.BadRequestException;
import org.nl.modules.security.service.dto.JwtUserDto;
import org.nl.modules.system.service.UserService;
import org.nl.modules.system.service.dto.RoleSmallDto;
import org.nl.modules.system.service.dto.UserDto;
import org.nl.modules.system.util.CodeUtil;
import org.nl.utils.SecurityUtils;
@@ -28,9 +33,13 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import java.io.InputStream;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* @author qinx
@@ -91,22 +100,22 @@ public class ProduceshiftorderServiceImpl implements ProduceshiftorderService {
}
WQLObject wo = WQLObject.getWQLObject("mps_bd_macoperaterecord");
JSONObject jsonObject = WQL.getWO("MPS_PRODUCEDURE001").addParamMap(map).pageQuery(WqlUtil.getHttpContext(page), "ShiftOrder.update_time desc");
JSONArray jsonArray = jsonObject.getJSONArray("content");
for (int i = 0; i < jsonArray.size(); i++) {
JSONObject arrayJSONObject = jsonArray.getJSONObject(i);
String produceorder_id = arrayJSONObject.getString("produceorder_id");
JSONArray resultJSONArray = wo.query("produceorder_id = '" + produceorder_id + "'", "operatetime_start desc").getResultJSONArray(0);
if (ObjectUtil.isNotEmpty(resultJSONArray)){
JSONObject resultJSONArrayJSONObject = resultJSONArray.getJSONObject(0);
String jockey_id = resultJSONArrayJSONObject.getString("jockey_id");
UserDto user = userService.findById(Long.valueOf(jockey_id));
String nick_name = "";
if (ObjectUtil.isNotEmpty(user)){
nick_name = user.getNickName();
}
arrayJSONObject.put("jockey_name",nick_name);
}
}
// JSONArray jsonArray = jsonObject.getJSONArray("content");
// for (int i = 0; i < jsonArray.size(); i++) {
// JSONObject arrayJSONObject = jsonArray.getJSONObject(i);
// String produceorder_id = arrayJSONObject.getString("produceorder_id");
// JSONArray resultJSONArray = wo.query("produceorder_id = '" + produceorder_id + "'", "operatetime_start desc").getResultJSONArray(0);
// if (ObjectUtil.isNotEmpty(resultJSONArray)){
// JSONObject resultJSONArrayJSONObject = resultJSONArray.getJSONObject(0);
// String jockey_id = resultJSONArrayJSONObject.getString("jockey_id");
// UserDto user = userService.findById(Long.valueOf(jockey_id));
// String nick_name = "";
// if (ObjectUtil.isNotEmpty(user)){
// nick_name = user.getNickName();
// }
// arrayJSONObject.put("jockey_name",nick_name);
// }
// }
return jsonObject;
}
@@ -131,7 +140,7 @@ public class ProduceshiftorderServiceImpl implements ProduceshiftorderService {
@Override
public ProduceshiftorderDto findByCode(String code) {
WQLObject wo = WQLObject.getWQLObject("mps_bd_produceshiftorder");
JSONObject json = wo.query("code ='" + code + "'").uniqueResult(0);
JSONObject json = wo.query("produceorder_code ='" + code + "'").uniqueResult(0);
if (ObjectUtil.isNotEmpty(json)) {
return json.toJavaObject(ProduceshiftorderDto.class);
}
@@ -149,7 +158,7 @@ public class ProduceshiftorderServiceImpl implements ProduceshiftorderService {
JwtUserDto currentUser = (JwtUserDto) SecurityUtils.getCurrentUser();
Long deptId = currentUser.getDeptId();
String newCode = CodeUtil.getNewCode("PDM_SHIFTORDER");
dto.setProduce_date(dto.getProduce_date().substring(0,10));
dto.setProduce_date(dto.getProduce_date().substring(0, 10));
dto.setProduceorder_id(IdUtil.getSnowflake(1, 1).nextId());
dto.setProduceorder_code(newCode);
dto.setProducedeviceorder_code(newCode);
@@ -236,30 +245,41 @@ public class ProduceshiftorderServiceImpl implements ProduceshiftorderService {
public JSONArray getTable(JSONObject param) {
//获取当前登录用户下的所有设备
Long currentUserId = SecurityUtils.getCurrentUserId();
JSONObject map1 = new JSONObject();
map1.put("flag", "2");
map1.put("jockey_id", currentUserId + "");
JSONArray devices = WQL.getWO("MPS_PRODUCEDURE001").addParamMap(map1).process().getResultJSONArray(0);
//根据当前用户下的所有设备查询所属工序
// JSONObject map1 = new JSONObject();
// map1.put("flag", "2");
// map1.put("jockey_id", currentUserId + "");
// JSONArray devices = WQL.getWO("MPS_PRODUCEDURE001").addParamMap(map1).process().getResultJSONArray(0);
// //根据当前用户下的所有设备查询所属工序
// JSONObject map = new JSONObject();
// map.put("flag", "3");
// StringBuilder sb = new StringBuilder();
// if (ObjectUtil.isNotEmpty(devices)) {
// sb.append("(");
// for (int i = 0; i < devices.size(); i++) {
// JSONObject device = devices.getJSONObject(i);
// String workprocedure_id = device.getString("workprocedure_id");
// if (devices.size() - 1 == i) {
// sb.append("'" + workprocedure_id + "')");
// }
// if (devices.size() - 1 != i) {
// sb.append("'" + workprocedure_id + "',");
// }
// }
// map.put("workprocedure_ids", sb.toString());
// } else {
// map.put("workprocedure_ids", "('-1')");
// }
UserDto userDto = userService.findById(currentUserId);
// Set<RoleSmallDto> roles = userDto.getRoles();
// boolean b = roles.contains("");
Boolean isAdmin = userDto.getIsAdmin();
String jockey_id = String.valueOf(currentUserId);
if (isAdmin) {
jockey_id = "";
}
JSONObject map = new JSONObject();
map.put("flag", "3");
StringBuilder sb = new StringBuilder();
if (ObjectUtil.isNotEmpty(devices)) {
sb.append("(");
for (int i = 0; i < devices.size(); i++) {
JSONObject device = devices.getJSONObject(i);
String workprocedure_id = device.getString("workprocedure_id");
if (devices.size() - 1 == i) {
sb.append("'" + workprocedure_id + "')");
}
if (devices.size() - 1 != i) {
sb.append("'" + workprocedure_id + "',");
}
}
map.put("workprocedure_ids", sb.toString());
} else {
map.put("workprocedure_ids", "('-1')");
}
map.put("jockey_id", jockey_id);
//根据当前用户的设备所属的工序查询属于自己的工单表
JSONArray resultJSONArray = WQL.getWO("MPS_PRODUCEDURE001").addParamMap(map).process().getResultJSONArray(0);
return resultJSONArray;
@@ -268,15 +288,19 @@ public class ProduceshiftorderServiceImpl implements ProduceshiftorderService {
@Override
@Transactional(rollbackFor = Exception.class)
public void openStart(JSONObject param) {
WQLObject wo = WQLObject.getWQLObject("MPS_BD_ProduceShiftOrder");
Long currentUserId = SecurityUtils.getCurrentUserId();
String nickName = SecurityUtils.getNickName();
String now = DateUtil.now();
String device_id = param.getString("device_id");
WQLObject wo_device = WQLObject.getWQLObject("pdm_bi_device");
JSONObject device = wo_device.query("device_id = '" + device_id + "'").uniqueResult(0);
String device_code = device.getString("device_code");
//获取前台传入的开工的工单信息
JSONObject row = param.getJSONObject("row");
String device_id = row.getString("device_id");
String produceorder_id = row.getString("produceorder_id");
JSONObject result = wo.query("device_id = '" + device_id + "' and (order_status = '02' or order_status = '03') and produceorder_id != '" + produceorder_id + "'").uniqueResult(0);
if (ObjectUtil.isNotEmpty(result)) {
throw new BadRequestException("已有工单选择该设备开工,请更换开工设备!");
}
String workprocedure_id = row.getString("workprocedure_id");
String produceorder_code = row.getString("produceorder_code");
String material_id = row.getString("material_id");
@@ -286,17 +310,19 @@ public class ProduceshiftorderServiceImpl implements ProduceshiftorderService {
String is_needmove = row.getString("is_needmove");
String plan_qty = row.getString("plan_qty");
String order_status = row.getString("order_status");
//根据设备id获取设备编码 传给acs用
WQLObject wo_device = WQLObject.getWQLObject("pdm_bi_device");
JSONObject device = wo_device.query("device_id = '" + device_id + "'").uniqueResult(0);
String device_code = device.getString("device_code");
//开工时修改生产班次工单表 生产设备、以及工单状态
WQLObject wo = WQLObject.getWQLObject("MPS_BD_ProduceShiftOrder");
JSONObject jsonObject1 = wo.query("produceorder_id = '" + produceorder_id + "'").uniqueResult(0);
JSONObject produceorderMap = new JSONObject();
produceorderMap.put("produceorder_id", produceorder_id);
produceorderMap.put("device_id", device_id);
produceorderMap.put("order_status", "02");
produceorderMap.put("update_optid", currentUserId);
produceorderMap.put("update_optname", nickName);
produceorderMap.put("update_time", now);
if (order_status.equals("01")){
if (order_status.equals("01")) {
produceorderMap.put("realproducestart_date", now);
}
wo.update(produceorderMap);
@@ -316,20 +342,24 @@ public class ProduceshiftorderServiceImpl implements ProduceshiftorderService {
//同时向acs系统下发工单 问题是现在一个工单分多次执行现在是每开工一次向acs发送一次工单
//acs那边就会新增多个工单
//如果是第一次开工就向acs下发工单
// TODO
JSONArray array = new JSONArray();
JSONObject acsObj = new JSONObject();
acsObj.put("ext_order_id",produceorder_id);
acsObj.put("is_needmove",is_needmove);
acsObj.put("order_code",produceorder_code);
acsObj.put("qty",plan_qty);
acsObj.put("material_uuid",material_id);
acsObj.put("material_code",material_code);
acsObj.put("material_name",material_name);
acsObj.put("material_spec",material_spec);
acsObj.put("device_code",device_code);
acsObj.put("ext_order_id", produceorder_id);
acsObj.put("is_needmove", is_needmove);
acsObj.put("order_code", produceorder_code);
acsObj.put("qty", plan_qty);
acsObj.put("material_uuid", material_id);
acsObj.put("material_code", material_code);
acsObj.put("material_name", material_name);
acsObj.put("material_spec", material_spec);
acsObj.put("device_code", device_code);
array.add(acsObj);
wmsToAcsService.order(array);
Map<String, Object> resp = wmsToAcsService.order(array);
String status = String.valueOf(resp.get("status"));
String message = (String) resp.get("message");
if (!status.equals("200")) {
throw new BadRequestException(message);
}
} else {
Integer sum = 0;
//如果生产过了,就获取记录表中的报工数量,用计划数量减去生产过的报工数量的和,为这次的生产数量
@@ -345,10 +375,15 @@ public class ProduceshiftorderServiceImpl implements ProduceshiftorderService {
// TODO
JSONArray array = new JSONArray();
JSONObject map = new JSONObject();
map.put("ext_order_id",produceorder_id);
map.put("type","2");
map.put("ext_order_id", produceorder_id);
map.put("type", "2");
array.add(map);
wmsToAcsService.orderStatusUpdate(array);
Map<String, Object> resp = wmsToAcsService.orderStatusUpdate(array);
String status = String.valueOf(resp.get("status"));
String message = (String) resp.get("message");
if (!status.equals("200")) {
throw new BadRequestException(message);
}
}
recordMap.put("operatetime_start", now);
recordMap.put("jockey_id", currentUserId);
@@ -368,12 +403,12 @@ public class ProduceshiftorderServiceImpl implements ProduceshiftorderService {
WQLObject wo = WQLObject.getWQLObject("MPS_BD_ProduceShiftOrder");
JSONObject jsonObject = wo.query("produceorder_id = '" + produceorder_id + "'").uniqueResult(0);
JSONObject produceorderMap = new JSONObject();
produceorderMap.put("produceorder_id",produceorder_id);
if (row.getString("report_qty").equals("0") || StrUtil.isEmpty(row.getString("report_qty"))){
produceorderMap.put("report_qty",report_qty);
}else {
produceorderMap.put("produceorder_id", produceorder_id);
if (row.getString("report_qty").equals("0") || StrUtil.isEmpty(row.getString("report_qty"))) {
produceorderMap.put("report_qty", report_qty);
} else {
Integer sum = Integer.parseInt(row.getString("report_qty")) + Integer.parseInt(report_qty);
produceorderMap.put("report_qty",sum);
produceorderMap.put("report_qty", sum);
}
produceorderMap.put("order_status", "03");
produceorderMap.put("update_optid", currentUserId);
@@ -383,20 +418,20 @@ public class ProduceshiftorderServiceImpl implements ProduceshiftorderService {
//同时修改这条工单对应的记录表中最新的一条数据的报工数量
WQLObject wo_record = WQLObject.getWQLObject("MPS_BD_MacOperateRecord");
//获取最新的工单的对应记录信息
JSONObject newRecord = wo_record.query("produceorder_id = '"+produceorder_id+"' and (operatetime_end is null or operatetime_end = '')").uniqueResult(0);
newRecord.put("report_qty",report_qty);
newRecord.put("finish_qty",jsonObject.getString("real_qty"));
JSONObject newRecord = wo_record.query("produceorder_id = '" + produceorder_id + "' and (operatetime_end is null or operatetime_end = '')").uniqueResult(0);
newRecord.put("report_qty", report_qty);
newRecord.put("finish_qty", jsonObject.getString("real_qty"));
Integer finishproduct_qty = Integer.parseInt(jsonObject.getString("real_qty")) - Integer.parseInt(newRecord.getString("init_qty"));
newRecord.put("finishproduct_qty",finishproduct_qty);
newRecord.put("operatetime_end",now);
newRecord.put("finishproduct_qty", finishproduct_qty);
newRecord.put("operatetime_end", now);
wo_record.update(newRecord);
//wms向acs发送请求 工单暂停
// 报工的时候同时向acs发送工单暂停状态
// TODO
JSONArray array = new JSONArray();
JSONObject map = new JSONObject();
map.put("ext_order_id",produceorder_id);
map.put("type","1");
map.put("ext_order_id", produceorder_id);
map.put("type", "1");
array.add(map);
wmsToAcsService.orderStatusUpdate(array);
}
@@ -411,9 +446,10 @@ public class ProduceshiftorderServiceImpl implements ProduceshiftorderService {
//强制完成时修改工单状态
String produceorder_id = row.getString("produceorder_id");
WQLObject wo = WQLObject.getWQLObject("MPS_BD_ProduceShiftOrder");
ProduceshiftorderDto produceshiftorderDto = this.findById(Long.parseLong(produceorder_id));
JSONObject produceorderMap = new JSONObject();
produceorderMap.put("produceorder_id",produceorder_id);
produceorderMap.put("order_status","04");
produceorderMap.put("produceorder_id", produceorder_id);
produceorderMap.put("order_status", "04");
produceorderMap.put("update_optid", currentUserId);
produceorderMap.put("device_id", null);
produceorderMap.put("update_optname", nickName);
@@ -422,26 +458,29 @@ public class ProduceshiftorderServiceImpl implements ProduceshiftorderService {
wo.update(produceorderMap);
JSONObject jsonObject = wo.query("produceorder_id = '" + produceorder_id + "'").uniqueResult(0);
String real_qty = jsonObject.getString("real_qty");
if (StrUtil.isEmpty(real_qty)){
if (StrUtil.isEmpty(real_qty)) {
real_qty = "0";
}
//同时修改工单记录表中的期末数量及完成数量
WQLObject wo_record = WQLObject.getWQLObject("MPS_BD_MacOperateRecord");
JSONObject result = wo_record.query("produceorder_id = '" + produceorder_id + "' and (operatetime_end = '' or operatetime_end is null) ").uniqueResult(0);
if (ObjectUtil.isNotEmpty(result)){
result.put("finish_qty",real_qty);
result.put("finishproduct_qty",real_qty);
result.put("operatetime_end",now);
if (ObjectUtil.isNotEmpty(result)) {
result.put("finish_qty", real_qty);
result.put("finishproduct_qty", real_qty);
result.put("operatetime_end", now);
wo_record.update(result);
}
//wms向acs发送请求 工单强制完成
//工单开工以后需要向acs强制完成 wms向acs发送请求 工单强制完成
// TODO
JSONArray array = new JSONArray();
JSONObject map = new JSONObject();
map.put("ext_order_id",produceorder_id);
map.put("type","3");
array.add(map);
wmsToAcsService.orderStatusUpdate(array);
String order_status = produceshiftorderDto.getOrder_status();
if (!order_status.equals("00") && !order_status.equals("01")) {
JSONArray array = new JSONArray();
JSONObject map = new JSONObject();
map.put("ext_order_id", produceorder_id);
map.put("type", "3");
array.add(map);
wmsToAcsService.orderStatusUpdate(array);
}
}
@Override
@@ -451,11 +490,11 @@ public class ProduceshiftorderServiceImpl implements ProduceshiftorderService {
JSONObject jsonProduceShiftOrder = wo.query("produceorder_id = '" + produceorder_id + "'").uniqueResult(0);
WQLObject wo_record = WQLObject.getWQLObject("MPS_BD_MacOperateRecord");
//获取最新的工单的对应记录信息
JSONObject jsonObject = wo_record.query("produceorder_id = '"+produceorder_id+"' and (operatetime_end is null or operatetime_end = '')").uniqueResult(0);
JSONObject jsonObject = wo_record.query("produceorder_id = '" + produceorder_id + "' and (operatetime_end is null or operatetime_end = '')").uniqueResult(0);
String finish_qty = jsonProduceShiftOrder.getString("real_qty");
jsonObject.put("finish_qty",finish_qty);
jsonObject.put("finish_qty", finish_qty);
Integer finishproduct_qty = Integer.parseInt(finish_qty) - Integer.parseInt(jsonObject.getString("init_qty"));
jsonObject.put("finishproduct_qty",finishproduct_qty);
jsonObject.put("finishproduct_qty", finishproduct_qty);
return jsonObject;
}
@@ -469,10 +508,222 @@ public class ProduceshiftorderServiceImpl implements ProduceshiftorderService {
public JSONArray getDtl(JSONObject param) {
final String produceorder_id = param.getString("produceorder_id");
JSONObject map = new JSONObject();
map.put("flag","5");
map.put("produceorder_id",produceorder_id);
map.put("flag", "5");
map.put("produceorder_id", produceorder_id);
JSONArray resultJSONArray = WQL.getWO("MPS_PRODUCEDURE001").addParamMap(map).process().getResultJSONArray(0);
return resultJSONArray;
}
@Override
@Transactional(rollbackFor = Exception.class)
public void excelImport(MultipartFile file, HttpServletRequest request) {
if (file.isEmpty()) {
throw new BadRequestException("文件为空,请添加数据后重新导入");
}
Long currentUserId = SecurityUtils.getCurrentUserId();
String nickName = SecurityUtils.getNickName();
String now = DateUtil.now();
// 1.获取上传文件输入流
InputStream inputStream = null;
try {
inputStream = file.getInputStream();
} catch (Exception e) {
e.printStackTrace();
}
//工单表
WQLObject wo_order = WQLObject.getWQLObject("MPS_BD_ProduceShiftOrder");
//物料表
WQLObject wo_material = WQLObject.getWQLObject("md_me_materialbase");
//设备表
WQLObject wo_device = WQLObject.getWQLObject("pdm_bi_device");
//工序表
WQLObject wo_workprocedure = WQLObject.getWQLObject("pdm_bi_workprocedure");
//人员表
//WQLObject wo_user = WQLObject.getWQLObject("sys_user");
// 调用用 hutool 方法读取数据 默认调用第一个sheet
ExcelReader excelReader = ExcelUtil.getReader(inputStream);
// 从第二行开始获取数据 excelReader.read的结果是一个2纬的list外层是行内层是行对应的所有列
List<List<Object>> read = excelReader.read(1, excelReader.getRowCount());
// 循环获取的数据
for (int i = 0; i < read.size(); i++) {
List list = read.get(i);
JSONObject param = new JSONObject();
//按照列获取
param.put("produceorder_id", IdUtil.getSnowflake(1, 1).nextId());
param.put("produceorder_code", CodeUtil.getNewCode("PDM_SHIFTORDER"));
param.put("producedeviceorder_code", CodeUtil.getNewCode("PDM_SHIFTORDER"));
param.put("order_status", "00");
param.put("order_type_scode", "01");
//物料
String material_code = list.get(12).toString();
JSONObject json_material = wo_material.query("is_delete = '0' and material_code = '" + material_code + "'").uniqueResult(0);
if (ObjectUtil.isEmpty(json_material)) {
throw new BadRequestException("第'" + (i + 2) + "'行,物料编码不存在");
}
param.put("material_id", json_material.getString("material_id"));
//工序
String workprocedure_code = list.get(13).toString();
JSONObject jsonWorkprocedure = wo_workprocedure.query("is_delete = '0' and workprocedure_code = '" + workprocedure_code + "'").uniqueResult(0);
if (ObjectUtil.isEmpty(jsonWorkprocedure)) {
throw new BadRequestException("第'" + (i + 2) + "'行,工序编码不存在");
}
String workprocedure_id = jsonWorkprocedure.getString("workprocedure_id");
param.put("workprocedure_id", workprocedure_id);
//设备
String device_code = list.get(14).toString();
JSONObject json_device = wo_device.query("is_delete = '0' and device_code = '" + device_code + "'").uniqueResult(0);
if (ObjectUtil.isEmpty(json_device)) {
throw new BadRequestException("第'" + (i + 2) + "'行,设备编码不存在");
}
if (!workprocedure_id.equals(json_device.getString("workprocedure_id"))) {
throw new BadRequestException("第'" + (i + 2) + "'行,设备与所属工序不匹配");
}
param.put("device_id", json_device.getString("device_id"));
//单重
param.put("material_weight", list.get(5).toString());
param.put("plan_qty", list.get(7).toString());
//生产人员
String username_code = list.get(15).toString();
UserDto jsonUser = userService.findByName(username_code);
//JSONObject jsonUser = wo_user.query("is_delete = '0' and username = '" + username_code + "'").uniqueResult(0);
if (ObjectUtil.isEmpty(jsonUser)) {
throw new BadRequestException("第'" + (i + 2) + "'行,生产人员编码不存在");
}
param.put("jockey_id", jsonUser.getId());
//生产日期
String produce_date = list.get(16).toString();
if (StrUtil.isEmpty(produce_date)) {
throw new BadRequestException("第'" + (i + 2) + "'行,生产日期不能为空");
}
param.put("produce_date", produce_date);
//班次类型
String shift_type_scode = list.get(17).toString();
String type_scode = "01";
if (shift_type_scode.equals("夜班")) {
type_scode = "02";
}
param.put("shift_type_scode", type_scode);
//允许修改报工数量
String is_canupdate_update = list.get(18).toString();
String is_canupdate = "0";
if (is_canupdate_update.equals("")) {
is_canupdate = "1";
}
param.put("is_canupdate_update", is_canupdate);
//是否agv搬运
String is_needmove = list.get(19).toString();
String needmoce = "0";
if (is_needmove.equals("")) {
needmoce = "1";
}
param.put("is_needmove", needmoce);
String planproducestart_date = "";
String planproduceend_date = "";
if (type_scode.equals("01")) {
planproducestart_date = produce_date + " 07:30:00";
planproduceend_date = produce_date + " 18:30:00";
} else {
planproducestart_date = produce_date + " 18:30:00";
DateTime dateTime = DateUtil.parse(produce_date, "yyyy-MM-dd");
DateTime time = DateUtil.offset(dateTime, DateField.DAY_OF_MONTH, 1);
String format = DateUtil.format(time, "yyyy-MM-dd");
planproduceend_date = format + " 07:30:00";
}
param.put("planproducestart_date", planproducestart_date);
param.put("planproduceend_date", planproduceend_date);
param.put("create_id", currentUserId);
param.put("create_name", nickName);
param.put("create_time", now);
wo_order.insert(param);
}
}
@Override
public JSONArray getNotWorkDeviceByWorkproceduceId(JSONObject param) {
final String workproceduce_id = param.getString("workproceduce_id");
JSONObject map = new JSONObject();
map.put("flag", "6");
map.put("workproceduce_id", workproceduce_id);
JSONArray devices = WQL.getWO("MPS_PRODUCEDURE001").addParamMap(map).process().getResultJSONArray(0);
StringBuilder sb = new StringBuilder();
if (ObjectUtil.isNotEmpty(devices)) {
sb.append("(");
for (int i = 0; i < devices.size(); i++) {
JSONObject device = devices.getJSONObject(i);
String device_id = device.getString("device_id");
if (devices.size() - 1 == i) {
sb.append("'" + device_id + "')");
}
if (devices.size() - 1 != i) {
sb.append("'" + device_id + "',");
}
}
param.put("device_ids", sb.toString());
} else {
param.put("device_ids", "('-1')");
}
param.put("flag", "7");
param.put("workprocedure_id", workproceduce_id);
JSONArray resultJSONArray = WQL.getWO("MPS_PRODUCEDURE001").addParamMap(param).process().getResultJSONArray(0);
return resultJSONArray;
}
@Override
@Transactional
public void replaceDevice(JSONObject param) {
String produceorder_code = param.getString("produceorder_code");
String device_id = param.getString("device_id");
String device_code = param.getString("device_code");
Long currentUserId = SecurityUtils.getCurrentUserId();
String nickName = SecurityUtils.getNickName();
String now = DateUtil.now();
ProduceshiftorderDto produceshiftorderDto = this.findByCode(produceorder_code);
produceshiftorderDto.setDevice_id(Long.parseLong(device_id));
produceshiftorderDto.setUpdate_optid(currentUserId);
produceshiftorderDto.setUpdate_optname(nickName);
produceshiftorderDto.setUpdate_time(now);
String order_status = produceshiftorderDto.getOrder_status();
if (!order_status.equals("03") && !order_status.equals("01") && !order_status.equals("00")) {
JSONArray array = new JSONArray();
JSONObject acsObj = new JSONObject();
acsObj.put("order_code", produceorder_code);
acsObj.put("device_code", device_code);
array.add(acsObj);
Map<String, Object> resp = wmsToAcsService.replaceDevice(array);
String status = String.valueOf(resp.get("status"));
String message = (String) resp.get("message");
if (!status.equals("200")) {
throw new BadRequestException(message);
}
}
this.update(produceshiftorderDto);
}
@Override
public JSONArray getUser() {
List<UserDto> userDtos = userService.queryAll(null);
JSONArray re = new JSONArray();
for (int i = 0; i < userDtos.size(); i++) {
UserDto userDto = userDtos.get(i);
String id = String.valueOf(userDto.getId());
String nickName = userDto.getNickName();
JSONObject map = new JSONObject();
map.put("id", id);
map.put("nickName", nickName);
re.add(map);
}
return re;
}
}

View File

@@ -28,6 +28,7 @@
输入.product_series TYPEAS f_string
输入.workprocedure_ids TYPEAS f_string
输入.unFinish TYPEAS s_string
输入.device_ids TYPEAS f_string
[临时表]
@@ -65,13 +66,15 @@
classstandard.class_id,
classstandard.class_name,
device.device_code,
device.device_name
device.device_name,
user.nick_name as jockey_name
FROM
MPS_BD_ProduceShiftOrder ShiftOrder
left join pdm_bi_device device on ShiftOrder.device_id = device.device_id
LEFT JOIN md_me_materialbase material ON material.material_id = ShiftOrder.material_id
LEFT JOIN PDM_BI_WorkProcedure WorkProcedure ON WorkProcedure.workprocedure_id = ShiftOrder.workprocedure_id
LEFT JOIN md_pb_classstandard classstandard ON classstandard.class_id = material.product_series
LEFT JOIN sys_user user ON user.user_id = ShiftOrder.jockey_id
WHERE
ShiftOrder.is_delete = '0'
OPTION 输入.order_type_scode <> ""
@@ -145,7 +148,9 @@
left join pdm_bi_device device on device.device_id = shiftOrder.device_id
WHERE
shiftOrder.is_delete = '0' and shiftOrder.order_status in ('01', '02', '03')
and shiftOrder.workprocedure_id in 输入.workprocedure_ids
OPTION 输入.jockey_id <> ""
ShiftOrder.jockey_id = 输入.jockey_id
ENDOPTION
order by
shiftOrder.update_time desc
ENDSELECT
@@ -186,3 +191,33 @@
ENDQUERY
ENDIF
IF 输入.flag = "6"
QUERY
SELECT
shiftorder.device_id
from
mps_bd_produceshiftorder shiftorder
where
order_status <> '04'
and
shiftorder.workprocedure_id = '1535144427977314304'
and
(shiftorder.device_id <> null or shiftorder.device_id <> '')
ENDSELECT
ENDQUERY
ENDIF
IF 输入.flag = "7"
QUERY
SELECT
device.*
FROM
pdm_bi_device device
WHERE
device.is_delete = '0'
and device.workprocedure_id = 输入.workprocedure_id
and device.device_id not in 输入.device_ids
ENDSELECT
ENDQUERY
ENDIF

View File

@@ -108,4 +108,12 @@ public class DeviceController {
return new ResponseEntity<>(HttpStatus.OK);
}
@GetMapping("/queryById/{device_id}")
@Log("查询生产设备")
@ApiOperation("查询生产设备")
//@PreAuthorize("@el.check('device:list')")
public ResponseEntity<Object> queryById(@PathVariable("device_id") String device_id){
return new ResponseEntity<>(deviceService.queryById(device_id),HttpStatus.OK);
}
}

View File

@@ -78,4 +78,6 @@ public interface DeviceService {
Map<String,Object> getItemByDeviceId(JSONObject param);
void copyAdd(JSONObject param);
DeviceDto queryById(String device_id);
}

View File

@@ -273,4 +273,10 @@ public class DeviceServiceImpl implements DeviceService {
}
}
@Override
public DeviceDto queryById(String device_id) {
DeviceDto deviceDto = this.findById(Long.parseLong(device_id));
return deviceDto;
}
}

View File

@@ -33,14 +33,16 @@ public class AcsUtil {
.body(String.valueOf(list))
.execute().body();
result = JSONObject.parseObject(resultMsg);
if (!String.valueOf(result.get("status")).equals("400")){
result.put("status",200);
}
} catch (Exception e) {
String msg = e.getMessage();
//ConnectException: Connection refused: connect
//网络不通
System.out.println(msg);
result.put("status", HttpStatus.BAD_REQUEST);
result.put("message", "网络不通,操作失败!");
result.put("message", msg);
result.put("data", new JSONObject());
}
//acs抛异常这里

View File

@@ -75,8 +75,8 @@ spring:
#数据库索引
database: ${REDIS_DB:1}
host: ${REDIS_HOST:127.0.0.1}
# host: ${REDIS_HOST:localhost}
#host: ${REDIS_HOST:127.0.0.1}
host: ${REDIS_HOST:localhost}
port: ${REDIS_PORT:6379}
password: ${REDIS_PWD:}
#连接超时时间

View File

@@ -8,16 +8,16 @@ spring:
druid:
db-type: com.alibaba.druid.pool.DruidDataSource
driverClassName: net.sf.log4jdbc.sql.jdbcapi.DriverSpy
url: jdbc:log4jdbc:mysql://${DB_HOST:192.168.46.5}:${DB_PORT:3306}/${DB_NAME:hl_one_mes}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true&allowPublicKeyRetrieval=true&useSSL=false
url: jdbc:log4jdbc:mysql://${DB_HOST:127.0.0.1}:${DB_PORT:3306}/${DB_NAME:hl_one_mes}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true&allowPublicKeyRetrieval=true&useSSL=false
username: ${DB_USER:root}
password: ${DB_PWD:123456}
#password: ${DB_PWD:Root.123456}
# 初始连接数
initial-size: 5
initial-size: 15
# 最小连接数
min-idle: 15
min-idle: 45
# 最大连接数
max-active: 30
max-active: 90
# 是否自动回收超时连接
remove-abandoned: true
# 超时时间(以秒数为单位)
@@ -57,14 +57,14 @@ spring:
multi-statement-alagvslow: true
data:
mongodb:
host: 192.168.46.5
host: 127.0.0.1
port: 27017
database: nlacs
redis:
#数据库索引
database: ${REDIS_DB:6}
host: ${REDIS_HOST:192.168.46.5}
host: ${REDIS_HOST:127.0.0.1}
#host: ${REDIS_HOST:localhost}
port: ${REDIS_PORT:6379}
password: ${REDIS_PWD:}
@@ -162,5 +162,5 @@ jetcache:
maxIdle: 200
maxTotal: 1000
uri:
- redis://192.168.46.5:6379
- redis://127.0.0.1:6379

View File

@@ -43,7 +43,7 @@ rsa:
private_key: MIIBUwIBADANBgkqhkiG9w0BAQEFAASCAT0wggE5AgEAAkEA0vfvyTdGJkdbHkB8mp0f3FE0GYP3AYPaJF7jUd1M0XxFSE2ceK3k2kw20YvQ09NJKk+OMjWQl9WitG9pB6tSCQIDAQABAkA2SimBrWC2/wvauBuYqjCFwLvYiRYqZKThUS3MZlebXJiLB+Ue/gUifAAKIg1avttUZsHBHrop4qfJCwAI0+YRAiEA+W3NK/RaXtnRqmoUUkb59zsZUBLpvZgQPfj1MhyHDz0CIQDYhsAhPJ3mgS64NbUZmGWuuNKp5coY2GIj/zYDMJp6vQIgUueLFXv/eZ1ekgz2Oi67MNCk5jeTF2BurZqNLR3MSmUCIFT3Q6uHMtsB9Eha4u7hS31tj1UWE+D+ADzp59MGnoftAiBeHT7gDMuqeJHPL4b+kC+gzV4FGTfhR9q3tTbklZkD2A==
logging:
file:
path: C:\logs\nlwms\
path: E:\logs\nlwms\
demo:
monitor:
server-url: https://www.demo-monitor.com