rev:增加规格统计分页,修改排产顺序,设备最后规格记录;
This commit is contained in:
@@ -17,8 +17,7 @@ public enum WorkerOrderEnum {
|
||||
AUTO_COMPLETE("自动完成", "5"),
|
||||
COMPLETE("完成", "6"),
|
||||
FORCE_COMPLETE("强制完成", "7"),
|
||||
CANCEL("取消", "8"),
|
||||
|
||||
CANCEL("取消", "8")
|
||||
;
|
||||
|
||||
|
||||
|
||||
@@ -390,7 +390,7 @@ public class ProduceshiftorderServiceImpl implements ProduceshiftorderService{
|
||||
}
|
||||
|
||||
/**
|
||||
* 完工操作
|
||||
* 完工
|
||||
* 设备状态枚举1-关机、2-开机、3-生产中、4-待机、5-故障
|
||||
*
|
||||
* @author gbx
|
||||
|
||||
@@ -79,6 +79,7 @@
|
||||
"success" ELSE "info"
|
||||
END AS type,
|
||||
d.device_code,
|
||||
d.aps_device_code,
|
||||
w.device_code FIRST,
|
||||
w.device_code SECOND,
|
||||
CASE
|
||||
@@ -109,7 +110,8 @@
|
||||
QUERY
|
||||
SELECT
|
||||
workorder.device_code,
|
||||
mater.material_spec
|
||||
mater.material_spec,
|
||||
aps_workorder_no
|
||||
FROM
|
||||
pdm_produce_workorder workorder
|
||||
LEFT JOIN md_me_materialbase mater ON workorder.material_id = mater.material_id
|
||||
@@ -124,8 +126,6 @@
|
||||
ENDOPTION
|
||||
GROUP BY
|
||||
workorder.device_code,workorder.material_id
|
||||
ORDER BY
|
||||
aps_workorder_no
|
||||
ENDSELECT
|
||||
ENDQUERY
|
||||
ENDIF
|
||||
|
||||
@@ -28,10 +28,7 @@ import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@@ -42,125 +39,135 @@ import java.util.stream.Collectors;
|
||||
@Api(tags = "生产设备管理")
|
||||
@RequestMapping("/api/device")
|
||||
@Slf4j
|
||||
public class PdmBiDeviceController{
|
||||
@Autowired
|
||||
private DeviceService deviceService;
|
||||
@Autowired
|
||||
private IPdmBiDeviceService iDeviceService;
|
||||
@Autowired
|
||||
private IPdmBiWorkprocedureService pdmBiWorkprocedureService;
|
||||
public class PdmBiDeviceController {
|
||||
@Autowired
|
||||
private DeviceService deviceService;
|
||||
@Autowired
|
||||
private IPdmBiDeviceService iDeviceService;
|
||||
@Autowired
|
||||
private IPdmBiWorkprocedureService pdmBiWorkprocedureService;
|
||||
|
||||
@GetMapping
|
||||
@Log("查询生产设备")
|
||||
//("查询生产设备")
|
||||
@SaIgnore
|
||||
public ResponseEntity<Object> query(DeviceQuery query, PageQuery page) {
|
||||
Page<PdmBiDevice> result = iDeviceService.page(page.build(PdmBiDevice.class), query.build());
|
||||
return new ResponseEntity<>(TableDataInfo.build(result), HttpStatus.OK);
|
||||
}
|
||||
@GetMapping
|
||||
@Log("查询生产设备")
|
||||
//("查询生产设备")
|
||||
@SaIgnore
|
||||
public ResponseEntity<Object> query(DeviceQuery query, PageQuery page) {
|
||||
Page<PdmBiDevice> result = iDeviceService.page(page.build(PdmBiDevice.class), query.build());
|
||||
return new ResponseEntity<>(TableDataInfo.build(result), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/list")
|
||||
@Log("查询生产设备列表")
|
||||
//("查询生产设备列表")
|
||||
@SaIgnore
|
||||
public ResponseEntity<Object> queryList(@RequestBody DeviceQuery query) {
|
||||
List<Map<String,Object>> list = iDeviceService.listMaps(query.build().select("device_code", "device_name"));
|
||||
return new ResponseEntity<>(TableDataInfo.build(list), HttpStatus.OK);
|
||||
}
|
||||
@PostMapping("/list")
|
||||
@Log("查询生产设备列表")
|
||||
//("查询生产设备列表")
|
||||
@SaIgnore
|
||||
public ResponseEntity<Object> queryList(@RequestBody DeviceQuery query) {
|
||||
List<Map<String, Object>> list = iDeviceService.listMaps(query.build().select("device_code", "device_name"));
|
||||
return new ResponseEntity<>(TableDataInfo.build(list), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
@Log("新增生产设备")
|
||||
//("新增生产设备")
|
||||
//@PreAuthorize("@el.check('device:add')")
|
||||
public ResponseEntity<Object> create(@RequestBody JSONObject form) {
|
||||
PdmBiDevice device = form.toJavaObject(PdmBiDevice.class);
|
||||
device.setCreate_id(SecurityUtils.getCurrentUserId());
|
||||
device.setCreate_name(SecurityUtils.getCurrentNickName());
|
||||
device.setCreate_time(DateUtil.now());
|
||||
iDeviceService.save(device);
|
||||
return new ResponseEntity<>(HttpStatus.CREATED);
|
||||
}
|
||||
@PostMapping
|
||||
@Log("新增生产设备")
|
||||
//("新增生产设备")
|
||||
//@PreAuthorize("@el.check('device:add')")
|
||||
public ResponseEntity<Object> create(@RequestBody JSONObject form) {
|
||||
PdmBiDevice device = form.toJavaObject(PdmBiDevice.class);
|
||||
device.setCreate_id(SecurityUtils.getCurrentUserId());
|
||||
device.setCreate_name(SecurityUtils.getCurrentNickName());
|
||||
device.setCreate_time(DateUtil.now());
|
||||
iDeviceService.save(device);
|
||||
return new ResponseEntity<>(HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
@Log("修改生产设备")
|
||||
//("修改生产设备")
|
||||
//@PreAuthorize("@el.check('device:edit')")
|
||||
public ResponseEntity<Object> update(@Validated @RequestBody JSONObject form) {
|
||||
PdmBiDevice device = form.toJavaObject(PdmBiDevice.class);
|
||||
device.setUpdate_id(SecurityUtils.getCurrentUserId());
|
||||
device.setUpdate_name(SecurityUtils.getCurrentNickName());
|
||||
device.setUpdate_time(DateUtil.now());
|
||||
iDeviceService.updateById(device);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
@PutMapping
|
||||
@Log("修改生产设备")
|
||||
//("修改生产设备")
|
||||
//@PreAuthorize("@el.check('device:edit')")
|
||||
public ResponseEntity<Object> update(@Validated @RequestBody JSONObject form) {
|
||||
PdmBiDevice device = form.toJavaObject(PdmBiDevice.class);
|
||||
device.setUpdate_id(SecurityUtils.getCurrentUserId());
|
||||
device.setUpdate_name(SecurityUtils.getCurrentNickName());
|
||||
device.setUpdate_time(DateUtil.now());
|
||||
iDeviceService.updateById(device);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@Log("删除生产设备")
|
||||
//("删除生产设备")
|
||||
//@PreAuthorize("@el.check('device:del')")
|
||||
@DeleteMapping
|
||||
public ResponseEntity<Object> delete(@RequestBody String[] ids) {
|
||||
deviceService.deleteAll(ids);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
@Log("删除生产设备")
|
||||
//("删除生产设备")
|
||||
//@PreAuthorize("@el.check('device:del')")
|
||||
@DeleteMapping
|
||||
public ResponseEntity<Object> delete(@RequestBody String[] ids) {
|
||||
deviceService.deleteAll(ids);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@GetMapping("/getWorkprocedure")
|
||||
@Log("工序下拉")
|
||||
public ResponseEntity<Object> getWorkprocedure() {
|
||||
return new ResponseEntity<>(pdmBiWorkprocedureService.list(new QueryWrapper<PdmBiWorkprocedure>().eq("is_used", true)), HttpStatus.OK);
|
||||
}
|
||||
@GetMapping("/getWorkprocedure")
|
||||
@Log("工序下拉")
|
||||
public ResponseEntity<Object> getWorkprocedure() {
|
||||
return new ResponseEntity<>(pdmBiWorkprocedureService.list(new QueryWrapper<PdmBiWorkprocedure>().eq("is_used", true)), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@GetMapping("/getDeviceList")
|
||||
@Log("设备下拉框")
|
||||
//("设备下拉框")
|
||||
//@PreAuthorize("@el.check('device:list')")
|
||||
public ResponseEntity<Object> getDeviceList() {
|
||||
return new ResponseEntity<>(deviceService.getDeviceList(), HttpStatus.OK);
|
||||
}
|
||||
@GetMapping("/getDeviceList")
|
||||
@Log("设备下拉框")
|
||||
//("设备下拉框")
|
||||
//@PreAuthorize("@el.check('device:list')")
|
||||
public ResponseEntity<Object> getDeviceList() {
|
||||
return new ResponseEntity<>(deviceService.getDeviceList(), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/query")
|
||||
@Log("根据选项卡下标获取设备信息")
|
||||
//("根据选项卡下标获取设备信息")
|
||||
public ResponseEntity<Object> query(@RequestBody String card_index) {
|
||||
//工单排产调整通过工序选项卡下标获取设备信息
|
||||
WorkOrderImportEnum workOrderImportEnum = WorkOrderImportEnum.getIdByIndex(Integer.parseInt(card_index));
|
||||
Map param = new HashMap();
|
||||
param.put("flag", "2");
|
||||
param.put("workprocedure_id", workOrderImportEnum.getId());
|
||||
JSONArray array = WQL.getWO("QUERY_DEVICE").addParamMap(param).process().getResultJSONArray(0);
|
||||
// 收集需要查询的参数
|
||||
List<String> deviceCodes = new ArrayList<>();
|
||||
List<JSONObject> deviceList = new ArrayList<>();
|
||||
array.stream().map(obj -> (JSONObject) obj).filter(obj -> obj.get("first") != null).forEach(obj ->
|
||||
{
|
||||
deviceCodes.add(obj.getString("first"));
|
||||
deviceList.add(obj);
|
||||
});
|
||||
if(deviceList.size() > 0) {
|
||||
String joinedDeviceCodes = deviceCodes.stream().filter(s -> !s.trim().isEmpty()).map(s -> "'" + s + "'").collect(Collectors.joining(","));
|
||||
param.put("flag", "3");
|
||||
param.put("device_code", joinedDeviceCodes);
|
||||
JSONArray specInfoMap = WQL.getWO("QUERY_DEVICE").addParamMap(param).process().getResultJSONArray(0);
|
||||
Map<String,List<JSONObject>> groupedByDeviceCode = specInfoMap.stream().map(obj -> (JSONObject) obj).collect(Collectors.groupingBy(specInfo -> specInfo.getString("device_code")));
|
||||
groupedByDeviceCode.forEach((deviceCode, group) ->
|
||||
{
|
||||
for(JSONObject device : deviceList) {
|
||||
if(StringUtils.isNotBlank(device.getString("first"))) {
|
||||
if(device.getString("first").equals(deviceCode)) {
|
||||
device.put("type","success");
|
||||
device.put("first", group.get(0).getString("material_spec"));
|
||||
if(group.size() > 1) {
|
||||
device.put("second", group.get(1).getString("material_spec"));
|
||||
}
|
||||
}
|
||||
if(device.getString("second").equals(device.getString("device_code")))
|
||||
{
|
||||
device.put("second","");
|
||||
}
|
||||
}
|
||||
@PostMapping("/query")
|
||||
@Log("根据选项卡下标获取设备信息")
|
||||
//("根据选项卡下标获取设备信息")
|
||||
public ResponseEntity<Object> query(@RequestBody String card_index) {
|
||||
//工单排产调整通过工序选项卡下标获取设备信息
|
||||
WorkOrderImportEnum workOrderImportEnum = WorkOrderImportEnum.getIdByIndex(Integer.parseInt(card_index));
|
||||
Map param = new HashMap();
|
||||
param.put("flag", "2");
|
||||
param.put("workprocedure_id", workOrderImportEnum.getId());
|
||||
JSONArray array = WQL.getWO("QUERY_DEVICE").addParamMap(param).process().getResultJSONArray(0);
|
||||
// 收集需要查询的参数
|
||||
List<String> deviceCodes = new ArrayList<>();
|
||||
List<JSONObject> deviceList = new ArrayList<>();
|
||||
array.stream().map(obj -> (JSONObject) obj).filter(obj -> obj.get("first") != null).forEach(obj ->
|
||||
{
|
||||
deviceCodes.add(obj.getString("first"));
|
||||
deviceList.add(obj);
|
||||
});
|
||||
if (deviceList.size() > 0) {
|
||||
String joinedDeviceCodes = deviceCodes.stream().filter(s -> !s.trim().isEmpty()).map(s -> "'" + s + "'").collect(Collectors.joining(","));
|
||||
param.put("flag", "3");
|
||||
param.put("device_code", joinedDeviceCodes);
|
||||
JSONArray specInfoMap = WQL.getWO("QUERY_DEVICE").addParamMap(param).process().getResultJSONArray(0);
|
||||
Map<String, List<JSONObject>> groupedByDeviceCode = specInfoMap.stream().map(obj -> (JSONObject) obj).collect(Collectors.groupingBy(specInfo -> specInfo.getString("device_code")));
|
||||
groupedByDeviceCode.forEach((deviceCode, group) ->
|
||||
{
|
||||
for (JSONObject device : deviceList) {
|
||||
//设备有分派工单第一个工单的规格和第二个工单的规格
|
||||
if (StringUtils.isNotBlank(device.getString("first"))) {
|
||||
if (device.getString("first").equals(deviceCode)) {
|
||||
device.put("type", "success");
|
||||
List<Map> groups = group.stream()
|
||||
.filter(r -> StringUtils.isNotBlank(r.getString("material_spec")))
|
||||
.sorted(Comparator.comparingInt(r -> Integer.parseInt(r.getString("aps_workorder_no"))))
|
||||
.collect(Collectors.toList());
|
||||
if (groups.size() > 0) {
|
||||
device.put("first", groups.get(0).get("material_spec"));
|
||||
if (groups.size() > 1) {
|
||||
device.put("second", groups.get(1).get("material_spec"));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (device.getString("second").equals(device.getString("device_code"))) {
|
||||
device.put("second", "");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
return new ResponseEntity<>(deviceList, HttpStatus.OK);
|
||||
}
|
||||
else{
|
||||
//设备无分派工单,显示最后一次生产的规格
|
||||
device.put("first", device.get("aps_device_code"));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
return new ResponseEntity<>(deviceList, HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -233,13 +233,32 @@ public class PdmProduceWorkorderController{
|
||||
return new ResponseEntity<>(TableDataInfo.build(iPdmProduceWorkorderService.queryAdjustWorkOrder(query)), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/queryStatisticsSpec")
|
||||
@Log("根据规格统计工单信息")
|
||||
//("根据规格统计工单信息")
|
||||
public ResponseEntity<Object> queryStatisticsSpec(@RequestBody WorkorderQuery query) {
|
||||
return new ResponseEntity<>(TableDataInfo.build(iPdmProduceWorkorderService.queryStatisticsSpec(query)), HttpStatus.OK);
|
||||
// @PostMapping("/queryStatisticsSpec1")
|
||||
// @Log("根据规格统计工单信息")
|
||||
// //("根据规格统计工单信息")
|
||||
// public ResponseEntity<Object> queryStatisticsSpec1(@RequestBody WorkorderQuery query) {
|
||||
// return new ResponseEntity<>(TableDataInfo.build(iPdmProduceWorkorderService.queryStatisticsSpec(query)), HttpStatus.OK);
|
||||
// }
|
||||
|
||||
@PostMapping("/specOptionsSelect")
|
||||
@Log("规格统计规格下拉框")
|
||||
//("规格统计规格下拉框")
|
||||
public ResponseEntity<Object> specOptionsSelect() {
|
||||
return new ResponseEntity<>(TableDataInfo.build(iPdmProduceWorkorderService.specOptionsSelect()), HttpStatus.OK);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@GetMapping("/queryStatisticsSpec")
|
||||
@Log("根据规格统计工单信息")
|
||||
public ResponseEntity<Object> queryStatisticsSpec(WorkorderQuery query, PageQuery page) {
|
||||
return new ResponseEntity<>(iPdmProduceWorkorderService.queryStatisticsSpec(query, page), HttpStatus.OK);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@PostMapping("/queryMouldsSpec")
|
||||
@Log("根据设备统计装车信息")
|
||||
//("根据设备统计装车信息")
|
||||
|
||||
@@ -204,7 +204,12 @@ public interface IPdmProduceWorkorderService extends IService<PdmProduceWorkorde
|
||||
List<Map> queryAdjustWorkOrder(WorkorderQuery param);
|
||||
|
||||
|
||||
List<Map> queryStatisticsSpec(WorkorderQuery param);
|
||||
TableDataInfo queryStatisticsSpec(WorkorderQuery query,PageQuery page);
|
||||
|
||||
List<Map> specOptionsSelect();
|
||||
|
||||
|
||||
|
||||
|
||||
List<Map<String, Object>> queryMouldsSpec(WorkorderQuery param);
|
||||
|
||||
|
||||
@@ -70,6 +70,15 @@ public interface PdmProduceWorkorderMapper extends BaseMapper<PdmProduceWorkorde
|
||||
List<Map> queryDeviceCount(@Param("query") WorkorderQuery query);
|
||||
|
||||
|
||||
/**
|
||||
* 规格下拉框
|
||||
*
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
List<Map> specOptionsSelect();
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 根据规格统计工单信息
|
||||
@@ -79,6 +88,12 @@ public interface PdmProduceWorkorderMapper extends BaseMapper<PdmProduceWorkorde
|
||||
*/
|
||||
List<Map> queryStatisticsSpec(@Param("query") WorkorderQuery query);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 根据设备统计装车信息
|
||||
*
|
||||
|
||||
@@ -512,6 +512,23 @@
|
||||
${query.orderBy}
|
||||
</select>
|
||||
|
||||
<select id="specOptionsSelect" resultType="java.util.Map">
|
||||
SELECT
|
||||
mater.material_spec,
|
||||
mater.material_id
|
||||
FROM
|
||||
pdm_produce_workorder workorder
|
||||
LEFT JOIN md_me_materialbase mater ON workorder.material_id = mater.material_id
|
||||
WHERE
|
||||
workorder.is_delete = '0'
|
||||
AND workorder.aps_work_type != 'S'
|
||||
AND workorder.workorder_status = '1'
|
||||
AND mater.material_id IS NOT NULL
|
||||
GROUP BY
|
||||
mater.material_spec
|
||||
</select>
|
||||
|
||||
|
||||
<select id="queryStatisticsSpec" resultType="java.util.Map">
|
||||
SELECT
|
||||
w.workprocedure_name,
|
||||
@@ -533,11 +550,12 @@
|
||||
LEFT JOIN md_me_materialbase mater ON workorder.material_id = mater.material_id
|
||||
LEFT JOIN pdm_bi_workprocedure w ON workorder.workprocedure_id = w.workprocedure_id
|
||||
WHERE
|
||||
workorder.is_delete = '0' AND workorder.aps_work_type != 'S'
|
||||
workorder.is_delete = '0' AND workorder.aps_work_type != 'S' AND workorder.workorder_status ='1'
|
||||
<if test="query.material_id != null and query.material_id != ''">
|
||||
and workorder.material_id =#{query.material_id}
|
||||
</if>
|
||||
GROUP BY
|
||||
workorder.material_id
|
||||
ORDER BY
|
||||
${query.orderBy}
|
||||
mater.material_spec
|
||||
</select>
|
||||
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ public class WorkorderQuery extends BaseQuery<PdmProduceWorkorder> {
|
||||
private String titleSort;
|
||||
private String material;
|
||||
private String material_code;
|
||||
private String material_id;
|
||||
private String order_status;
|
||||
private String plan_start_time;
|
||||
private String plan_end_time;
|
||||
@@ -37,6 +38,7 @@ public class WorkorderQuery extends BaseQuery<PdmProduceWorkorder> {
|
||||
private String is_error;
|
||||
private Integer tabIndex;
|
||||
private String orderBy;
|
||||
private String orderBys;
|
||||
|
||||
|
||||
@Override
|
||||
|
||||
@@ -7,6 +7,7 @@ import cn.hutool.poi.excel.ExcelUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
@@ -180,12 +181,9 @@ public class IPdmProduceWorkorderServiceImpl extends ServiceImpl<PdmProduceWorko
|
||||
entity.setWorkorder_code(CodeUtil.getNewCode("PDM_SHIFTORDER"));
|
||||
String current_produce_person_id = form.getString("current_produce_person_id");
|
||||
entity.setCurrent_produce_person_id(current_produce_person_id);
|
||||
if (StringUtils.isEmpty(current_produce_person_id)){
|
||||
if (StringUtils.isEmpty(current_produce_person_id)) {
|
||||
entity.setCurrent_produce_person_id(SecurityUtils.getCurrentUserId());
|
||||
}
|
||||
if (StringUtils.isEmpty(current_produce_person_id)){
|
||||
entity.setCurrent_produce_person_id(SecurityUtils.getCurrentUserId());
|
||||
}
|
||||
entity.setCreate_id(SecurityUtils.getCurrentUserId());
|
||||
entity.setCreate_name(SecurityUtils.getCurrentNickName());
|
||||
entity.setCreate_time(DateUtil.now());
|
||||
@@ -239,8 +237,7 @@ public class IPdmProduceWorkorderServiceImpl extends ServiceImpl<PdmProduceWorko
|
||||
List<PdmProduceWorkorder> list = this.list(new QueryWrapper<PdmProduceWorkorder>().nested(i -> i.isNull("workorder_code").or().eq("workorder_code", "0").or().eq("workorder_code", "").or().eq("material_id", "0").or().eq("workprocedure_id", "0").or().eq("create_type", "3")).in("workorder_id", ids));
|
||||
//aps排产完成的工单,生成工单编号再下发
|
||||
if (list.size() > 0) {
|
||||
list.forEach(r ->
|
||||
{
|
||||
list.forEach(r -> {
|
||||
UpdateWrapper<PdmProduceWorkorder> updateWrapper = new UpdateWrapper<PdmProduceWorkorder>();
|
||||
updateWrapper.eq("workorder_id", r.getWorkorder_id());
|
||||
//updateWrapper.set("workorder_code", CodeUtil.getNewCode("PDM_SHIFTORDER"));
|
||||
@@ -279,8 +276,7 @@ public class IPdmProduceWorkorderServiceImpl extends ServiceImpl<PdmProduceWorko
|
||||
}
|
||||
//根据设备号和工序分组,进行下发顺序校验
|
||||
Map<String, List<PdmProduceWorkorder>> groupedWorkorders = workorders.stream().collect(Collectors.groupingBy(workorder -> workorder.getWorkprocedure_id() + "-" + workorder.getDevice_code()));
|
||||
groupedWorkorders.forEach((workprocedureId, workorderList) ->
|
||||
{
|
||||
groupedWorkorders.forEach((workprocedureId, workorderList) -> {
|
||||
if (!workorderList.isEmpty() && workprocedureId.contains("-")) {
|
||||
//4.批量下发,校验工单顺序是否相邻或相等,校验批量工单中的每个工单的设备,是否存在已下发的工单,如果存在,不允许继续下发
|
||||
compareWorkorderAdjoin(workorderList);
|
||||
@@ -360,10 +356,10 @@ public class IPdmProduceWorkorderServiceImpl extends ServiceImpl<PdmProduceWorko
|
||||
if (StringUtils.isEmpty(pdmProduceWorkorder.getWorkorder_code()) || "0".equals(pdmProduceWorkorder.getWorkorder_code())) {
|
||||
this.update(new UpdateWrapper<PdmProduceWorkorder>().eq("workorder_id", pdmProduceWorkorder.getWorkorder_id()).set("workorder_code", CodeUtil.getNewCode("PDM_SHIFTORDER")));
|
||||
}
|
||||
BigDecimal report_qty = pdmProduceWorkorder.getReport_qty();
|
||||
if (report_qty == null){
|
||||
report_qty = new BigDecimal(0);
|
||||
}
|
||||
BigDecimal report_qty = pdmProduceWorkorder.getReport_qty();
|
||||
if (report_qty == null) {
|
||||
report_qty = new BigDecimal(0);
|
||||
}
|
||||
// try {
|
||||
// //根据计划实际生产时间获取计算对应APS实际生产时间
|
||||
// Date interval2End = getDateEndFromInterval(pdmProduceWorkorder.getRealproducestart_date(), pdmProduceWorkorder.getPlanproduceend_date(), pdmProduceWorkorder.getAps_realproducestart_date());
|
||||
@@ -385,10 +381,11 @@ public class IPdmProduceWorkorderServiceImpl extends ServiceImpl<PdmProduceWorko
|
||||
pdmProduceWorkorder.setUpdate_id(SecurityUtils.getCurrentUserId());
|
||||
pdmProduceWorkorder.setUpdate_name(SecurityUtils.getCurrentNickName());
|
||||
this.updateById(pdmProduceWorkorder);
|
||||
|
||||
//更新刻字数量
|
||||
//todo 测试是否累加还是直接更新报工数量
|
||||
updateLetteringQty(pdmProduceWorkorder);
|
||||
//工单排产页面标记最后一个生产规格
|
||||
updateDeviceMaterial(pdmProduceWorkorder);
|
||||
JSONArray array = new JSONArray();
|
||||
JSONObject map = new JSONObject();
|
||||
map.put("workorder_id", workorder_id);
|
||||
@@ -403,6 +400,18 @@ public class IPdmProduceWorkorderServiceImpl extends ServiceImpl<PdmProduceWorko
|
||||
//this.recordWorkOrder(OptionRecord.OptionEnum.UPDATE, workorder_id);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 工单排产页面标记最后一个生产规格
|
||||
*/
|
||||
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
|
||||
public void updateDeviceMaterial(PdmProduceWorkorder workorder) {
|
||||
MdMeMaterialbase materialbase = materialbaseService.getOne(new LambdaUpdateWrapper<MdMeMaterialbase>().eq(MdMeMaterialbase::getMaterial_id, workorder.getMaterial_id()));
|
||||
if (materialbase != null) {
|
||||
deviceService.update(new UpdateWrapper<PdmBiDevice>().eq("device_code", workorder.getDevice_code()).set("aps_device_code", StringUtils.isBlank(materialbase.getMaterial_spec()) ? "" : materialbase.getMaterial_spec()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 工单报工
|
||||
*/
|
||||
@@ -443,6 +452,8 @@ public class IPdmProduceWorkorderServiceImpl extends ServiceImpl<PdmProduceWorko
|
||||
// } catch (ParseException e) {
|
||||
// throw new BadRequestException(e.getMessage());
|
||||
// }
|
||||
//工单排产页面标记最后一个生产规格
|
||||
updateDeviceMaterial(workorder);
|
||||
} else {
|
||||
//工单暂停
|
||||
workorder.setWorkorder_status(WorkerOrderEnum.STOP.getCode());
|
||||
@@ -550,125 +561,120 @@ public class IPdmProduceWorkorderServiceImpl extends ServiceImpl<PdmProduceWorko
|
||||
}
|
||||
}
|
||||
|
||||
private void 推弯(InputStream inputStream) {
|
||||
ExcelReader excelReader = ExcelUtil.getReader(inputStream, "推弯计划表");
|
||||
List<List<Object>> read = excelReader.read();
|
||||
// 循环获取的数据
|
||||
List<PdmProduceWorkorder> data = new ArrayList<>();
|
||||
Map<String,String> errorMap = new HashMap();
|
||||
List<String> workprodures = new ArrayList<>();
|
||||
List<String> materialSpecs = new ArrayList<>();
|
||||
List<String> persons = new ArrayList<>();
|
||||
row:
|
||||
for(int i = 0; i < read.size(); i++) {
|
||||
List<Object> list = read.get(i);
|
||||
if(ObjectUtil.isEmpty(list)) {
|
||||
continue;
|
||||
}
|
||||
PdmProduceWorkorder workorder = new PdmProduceWorkorder();
|
||||
packageForm(workorder);
|
||||
for(int j = 0; j < list.size(); j++) {
|
||||
String col = String.valueOf(list.get(j));
|
||||
解析cell:
|
||||
{ //如果是第一行 为生产日期
|
||||
if(i == 0 && j == 0) {
|
||||
continue row;
|
||||
}
|
||||
//如果第一列包含规格二字 则为表头 结束内循环列
|
||||
if(j == 0 && col.contains("班次")) {
|
||||
continue row;
|
||||
}
|
||||
if(j == 0) {
|
||||
//物料
|
||||
workorder.setShift_type_scode("晚班".equals(col) ? "2" : "1");
|
||||
}
|
||||
if(j == 1) {
|
||||
if("1".equals(workorder.getShift_type_scode())) {
|
||||
workorder.setPlanproduceend_date(col.substring(0, col.indexOf(" ")) + " 18:30:00");
|
||||
workorder.setPlanproducestart_date(col.substring(0, col.indexOf(" ")) + " 07:30:00");
|
||||
}
|
||||
else{
|
||||
workorder.setPlanproducestart_date(col.substring(0, col.indexOf(" ")) + " 18:30:00");
|
||||
workorder.setPlanproduceend_date(col.substring(0, col.indexOf(" ")) + " 07:30:00");
|
||||
}
|
||||
}
|
||||
if(j == 2) {
|
||||
//物料
|
||||
materialSpecs.add(col);
|
||||
workorder.setMaterial_id(col);
|
||||
}
|
||||
if(j == 3) {
|
||||
workprodures.add(col);
|
||||
workorder.setWorkprocedure_id(col);
|
||||
}
|
||||
if(j == 4) {
|
||||
//设备 A1_TW_
|
||||
String s = col.replaceAll("-", "_");
|
||||
if (StringUtils.isNotEmpty(s)){
|
||||
workorder.setDevice_code("A1_TW_" + s);
|
||||
}
|
||||
}
|
||||
if(j == 7) {
|
||||
//单重
|
||||
BigDecimal bigDecimal = BigDecimal.valueOf(Double.parseDouble(col) * 1000);
|
||||
private void 推弯(InputStream inputStream) {
|
||||
ExcelReader excelReader = ExcelUtil.getReader(inputStream, "推弯计划表");
|
||||
List<List<Object>> read = excelReader.read();
|
||||
// 循环获取的数据
|
||||
List<PdmProduceWorkorder> data = new ArrayList<>();
|
||||
Map<String, String> errorMap = new HashMap();
|
||||
List<String> workprodures = new ArrayList<>();
|
||||
List<String> materialSpecs = new ArrayList<>();
|
||||
List<String> persons = new ArrayList<>();
|
||||
row:
|
||||
for (int i = 0; i < read.size(); i++) {
|
||||
List<Object> list = read.get(i);
|
||||
if (ObjectUtil.isEmpty(list)) {
|
||||
continue;
|
||||
}
|
||||
PdmProduceWorkorder workorder = new PdmProduceWorkorder();
|
||||
packageForm(workorder);
|
||||
for (int j = 0; j < list.size(); j++) {
|
||||
String col = String.valueOf(list.get(j));
|
||||
解析cell:
|
||||
{ //如果是第一行 为生产日期
|
||||
if (i == 0 && j == 0) {
|
||||
continue row;
|
||||
}
|
||||
//如果第一列包含规格二字 则为表头 结束内循环列
|
||||
if (j == 0 && col.contains("班次")) {
|
||||
continue row;
|
||||
}
|
||||
if (j == 0) {
|
||||
//物料
|
||||
workorder.setShift_type_scode("晚班".equals(col) ? "2" : "1");
|
||||
}
|
||||
if (j == 1) {
|
||||
if ("1".equals(workorder.getShift_type_scode())) {
|
||||
workorder.setPlanproduceend_date(col.substring(0, col.indexOf(" ")) + " 18:30:00");
|
||||
workorder.setPlanproducestart_date(col.substring(0, col.indexOf(" ")) + " 07:30:00");
|
||||
} else {
|
||||
workorder.setPlanproducestart_date(col.substring(0, col.indexOf(" ")) + " 18:30:00");
|
||||
workorder.setPlanproduceend_date(col.substring(0, col.indexOf(" ")) + " 07:30:00");
|
||||
}
|
||||
}
|
||||
if (j == 2) {
|
||||
//物料
|
||||
materialSpecs.add(col);
|
||||
workorder.setMaterial_id(col);
|
||||
}
|
||||
if (j == 3) {
|
||||
workprodures.add(col);
|
||||
workorder.setWorkprocedure_id(col);
|
||||
}
|
||||
if (j == 4) {
|
||||
//设备 A1_TW_
|
||||
String s = col.replaceAll("-", "_");
|
||||
if (StringUtils.isNotEmpty(s)) {
|
||||
workorder.setDevice_code("A1_TW_" + s);
|
||||
}
|
||||
}
|
||||
if (j == 7) {
|
||||
//单重
|
||||
BigDecimal bigDecimal = BigDecimal.valueOf(Double.parseDouble(col) * 1000);
|
||||
// workorder.setMaterial_weight(bigDecimal.setScale(3, RoundingMode.HALF_UP));
|
||||
}
|
||||
if(j == 8) {
|
||||
persons.add(col);
|
||||
workorder.setCurrent_produce_person_id(col);
|
||||
}
|
||||
if(j == 9) {
|
||||
workorder.setPlan_qty(new BigDecimal(Long.parseLong(col)));
|
||||
}
|
||||
if(j == 13) {
|
||||
workorder.setIs_needmove("是".equals(col));
|
||||
}
|
||||
if(j == 14) {
|
||||
workorder.setRemark(col);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(CollectionUtils.isEmpty(errorMap)) {
|
||||
data.add(workorder);
|
||||
}
|
||||
}
|
||||
List<MdMeMaterialbase> tmp_material_specs = materialbaseService.list(new QueryWrapper<MdMeMaterialbase>().in("material_spec", materialSpecs));
|
||||
List<SysUser> tmp_sysUsers = userService.list(new QueryWrapper<SysUser>().in("person_name", persons));
|
||||
List<PdmBiWorkprocedure> tmp_workprocedure_names = workprocedureService.list(new QueryWrapper<PdmBiWorkprocedure>().in("workprocedure_name", workprodures));
|
||||
Map<String,PdmBiWorkprocedure> collect = tmp_workprocedure_names.stream().collect(HashMap::new, (k, v) -> k.put(v.getWorkprocedure_name(), v), HashMap::putAll);
|
||||
Map<String,SysUser> users = tmp_sysUsers.stream().collect(HashMap::new, (k, v) -> k.put(v.getPerson_name(), v), HashMap::putAll);
|
||||
Map<String,List<MdMeMaterialbase>> materialspecs = tmp_material_specs.stream().collect(Collectors.groupingBy(MdMeMaterialbase::getMaterial_spec));
|
||||
for(int i = 0; i < data.size(); i++) {
|
||||
PdmProduceWorkorder workorder = data.get(i);
|
||||
SysUser sysUser = users.get(workorder.getCurrent_produce_person_id());
|
||||
if(sysUser == null) {
|
||||
//errorMap.put("第" + (i + 1) + "行:", "账号:" + workorder.getCurrent_produce_person_id() + "不存在");
|
||||
workorder.setCurrent_produce_person_id(null);
|
||||
}
|
||||
else{
|
||||
workorder.setCurrent_produce_person_id(sysUser.getUser_id());
|
||||
}
|
||||
PdmBiWorkprocedure workprocedure = collect.get(workorder.getWorkprocedure_id());
|
||||
if(workprocedure == null) {
|
||||
errorMap.put("第" + (i + 1) + "行:", "工序名称:" + workorder.getWorkprocedure_id() + "不存在");
|
||||
}
|
||||
else{
|
||||
workorder.setWorkprocedure_id(workprocedure.getWorkprocedure_id());
|
||||
}
|
||||
List<MdMeMaterialbase> mdMeMaterialbases = materialspecs.get(workorder.getMaterial_id());
|
||||
if(!CollectionUtils.isEmpty(mdMeMaterialbases)) {
|
||||
if(mdMeMaterialbases.size() == 1) {
|
||||
workorder.setMaterial_id(mdMeMaterialbases.get(0).getMaterial_id());
|
||||
if (j == 8) {
|
||||
persons.add(col);
|
||||
workorder.setCurrent_produce_person_id(col);
|
||||
}
|
||||
else{
|
||||
Optional<MdMeMaterialbase> first = mdMeMaterialbases.stream().filter(mdMeMaterialbase -> mdMeMaterialbase.getMaterial_code().contains("S") && Pattern.matches("^[0-9]*$", mdMeMaterialbase.getMaterial_name().substring(mdMeMaterialbase.getMaterial_name().length() - 1))).findFirst();
|
||||
if(first.isPresent()) {
|
||||
workorder.setMaterial_id(first.get().getMaterial_id());
|
||||
}
|
||||
else{
|
||||
errorMap.put("第" + (i + 1) + "行:", "物料规格:" + workorder.getMaterial_id() + "不存在");
|
||||
}
|
||||
if (j == 9) {
|
||||
workorder.setPlan_qty(new BigDecimal(Long.parseLong(col)));
|
||||
}
|
||||
if (j == 13) {
|
||||
workorder.setIs_needmove("是".equals(col));
|
||||
}
|
||||
if (j == 14) {
|
||||
workorder.setRemark(col);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (CollectionUtils.isEmpty(errorMap)) {
|
||||
data.add(workorder);
|
||||
}
|
||||
}
|
||||
List<MdMeMaterialbase> tmp_material_specs = materialbaseService.list(new QueryWrapper<MdMeMaterialbase>().in("material_spec", materialSpecs));
|
||||
List<SysUser> tmp_sysUsers = userService.list(new QueryWrapper<SysUser>().in("person_name", persons));
|
||||
List<PdmBiWorkprocedure> tmp_workprocedure_names = workprocedureService.list(new QueryWrapper<PdmBiWorkprocedure>().in("workprocedure_name", workprodures));
|
||||
Map<String, PdmBiWorkprocedure> collect = tmp_workprocedure_names.stream().collect(HashMap::new, (k, v) -> k.put(v.getWorkprocedure_name(), v), HashMap::putAll);
|
||||
Map<String, SysUser> users = tmp_sysUsers.stream().collect(HashMap::new, (k, v) -> k.put(v.getPerson_name(), v), HashMap::putAll);
|
||||
Map<String, List<MdMeMaterialbase>> materialspecs = tmp_material_specs.stream().collect(Collectors.groupingBy(MdMeMaterialbase::getMaterial_spec));
|
||||
for (int i = 0; i < data.size(); i++) {
|
||||
PdmProduceWorkorder workorder = data.get(i);
|
||||
SysUser sysUser = users.get(workorder.getCurrent_produce_person_id());
|
||||
if (sysUser == null) {
|
||||
//errorMap.put("第" + (i + 1) + "行:", "账号:" + workorder.getCurrent_produce_person_id() + "不存在");
|
||||
workorder.setCurrent_produce_person_id(null);
|
||||
} else {
|
||||
workorder.setCurrent_produce_person_id(sysUser.getUser_id());
|
||||
}
|
||||
PdmBiWorkprocedure workprocedure = collect.get(workorder.getWorkprocedure_id());
|
||||
if (workprocedure == null) {
|
||||
errorMap.put("第" + (i + 1) + "行:", "工序名称:" + workorder.getWorkprocedure_id() + "不存在");
|
||||
} else {
|
||||
workorder.setWorkprocedure_id(workprocedure.getWorkprocedure_id());
|
||||
}
|
||||
List<MdMeMaterialbase> mdMeMaterialbases = materialspecs.get(workorder.getMaterial_id());
|
||||
if (!CollectionUtils.isEmpty(mdMeMaterialbases)) {
|
||||
if (mdMeMaterialbases.size() == 1) {
|
||||
workorder.setMaterial_id(mdMeMaterialbases.get(0).getMaterial_id());
|
||||
} else {
|
||||
Optional<MdMeMaterialbase> first = mdMeMaterialbases.stream().filter(mdMeMaterialbase -> mdMeMaterialbase.getMaterial_code().contains("S") && Pattern.matches("^[0-9]*$", mdMeMaterialbase.getMaterial_name().substring(mdMeMaterialbase.getMaterial_name().length() - 1))).findFirst();
|
||||
if (first.isPresent()) {
|
||||
workorder.setMaterial_id(first.get().getMaterial_id());
|
||||
} else {
|
||||
errorMap.put("第" + (i + 1) + "行:", "物料规格:" + workorder.getMaterial_id() + "不存在");
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
errorMap.put("第" + (i + 1) + "行:", "物料规格:" + workorder.getMaterial_id() + "不存在");
|
||||
@@ -681,170 +687,158 @@ public class IPdmProduceWorkorderServiceImpl extends ServiceImpl<PdmProduceWorko
|
||||
}
|
||||
}
|
||||
|
||||
private void 综合(InputStream inputStream) {
|
||||
ExcelReader excelReader = ExcelUtil.getReader(inputStream, 0);
|
||||
List<List<Object>> read = excelReader.read();
|
||||
// 循环获取的数据
|
||||
List<PdmProduceWorkorder> data = new ArrayList<>();
|
||||
Map<String,String> errorMap = new HashMap();
|
||||
List<String> workprodures = new ArrayList<>();
|
||||
List<String> materialSpecs = new ArrayList<>();
|
||||
List<String> persons = new ArrayList<>();
|
||||
row:
|
||||
for(int i = 0; i < read.size(); i++) {
|
||||
List<Object> list = read.get(i);
|
||||
if(ObjectUtil.isEmpty(list)) {
|
||||
continue;
|
||||
}
|
||||
PdmProduceWorkorder workorder = new PdmProduceWorkorder();
|
||||
packageForm(workorder);
|
||||
for(int j = 0; j < list.size(); j++) {
|
||||
String col = String.valueOf(list.get(j));
|
||||
解析cell:
|
||||
{ //如果是第一行 为生产日期
|
||||
if(i == 0 && j == 0) {
|
||||
continue row;
|
||||
}
|
||||
//如果第一列包含规格二字 则为表头 结束内循环列
|
||||
if(j == 0 && col.contains("班次")) {
|
||||
continue row;
|
||||
}
|
||||
if(j == 0) {
|
||||
workorder.setShift_type_scode("晚班".equals(col) ? "2" : "1");
|
||||
}
|
||||
if(j == 1) {
|
||||
if("1".equals(workorder.getShift_type_scode())) {
|
||||
workorder.setPlanproduceend_date(col.substring(0, col.indexOf(" ")) + " 18:30:00");
|
||||
workorder.setPlanproducestart_date(col.substring(0, col.indexOf(" ")) + " 07:30:00");
|
||||
}
|
||||
else{
|
||||
workorder.setPlanproducestart_date(col.substring(0, col.indexOf(" ")) + " 18:30:00");
|
||||
workorder.setPlanproduceend_date(col.substring(0, col.indexOf(" ")) + " 07:30:00");
|
||||
}
|
||||
}
|
||||
if(j == 2) {
|
||||
//物料
|
||||
materialSpecs.add(col);
|
||||
workorder.setMaterial_id(col);
|
||||
}
|
||||
if(j == 4) {
|
||||
workprodures.add(col);
|
||||
workorder.setWorkprocedure_id(col);
|
||||
}
|
||||
if(j == 5) {
|
||||
//设备 A1_TW_
|
||||
workorder.setDevice_code(col);
|
||||
}
|
||||
if(j == 9) {
|
||||
//单重
|
||||
BigDecimal bigDecimal = BigDecimal.valueOf(Double.parseDouble("#N/A".equals(col) ? "0.05" : col) * 1000);
|
||||
private void 综合(InputStream inputStream) {
|
||||
ExcelReader excelReader = ExcelUtil.getReader(inputStream, 0);
|
||||
List<List<Object>> read = excelReader.read();
|
||||
// 循环获取的数据
|
||||
List<PdmProduceWorkorder> data = new ArrayList<>();
|
||||
Map<String, String> errorMap = new HashMap();
|
||||
List<String> workprodures = new ArrayList<>();
|
||||
List<String> materialSpecs = new ArrayList<>();
|
||||
List<String> persons = new ArrayList<>();
|
||||
row:
|
||||
for (int i = 0; i < read.size(); i++) {
|
||||
List<Object> list = read.get(i);
|
||||
if (ObjectUtil.isEmpty(list)) {
|
||||
continue;
|
||||
}
|
||||
PdmProduceWorkorder workorder = new PdmProduceWorkorder();
|
||||
packageForm(workorder);
|
||||
for (int j = 0; j < list.size(); j++) {
|
||||
String col = String.valueOf(list.get(j));
|
||||
解析cell:
|
||||
{ //如果是第一行 为生产日期
|
||||
if (i == 0 && j == 0) {
|
||||
continue row;
|
||||
}
|
||||
//如果第一列包含规格二字 则为表头 结束内循环列
|
||||
if (j == 0 && col.contains("班次")) {
|
||||
continue row;
|
||||
}
|
||||
if (j == 0) {
|
||||
workorder.setShift_type_scode("晚班".equals(col) ? "2" : "1");
|
||||
}
|
||||
if (j == 1) {
|
||||
if ("1".equals(workorder.getShift_type_scode())) {
|
||||
workorder.setPlanproduceend_date(col.substring(0, col.indexOf(" ")) + " 18:30:00");
|
||||
workorder.setPlanproducestart_date(col.substring(0, col.indexOf(" ")) + " 07:30:00");
|
||||
} else {
|
||||
workorder.setPlanproducestart_date(col.substring(0, col.indexOf(" ")) + " 18:30:00");
|
||||
workorder.setPlanproduceend_date(col.substring(0, col.indexOf(" ")) + " 07:30:00");
|
||||
}
|
||||
}
|
||||
if (j == 2) {
|
||||
//物料
|
||||
materialSpecs.add(col);
|
||||
workorder.setMaterial_id(col);
|
||||
}
|
||||
if (j == 4) {
|
||||
workprodures.add(col);
|
||||
workorder.setWorkprocedure_id(col);
|
||||
}
|
||||
if (j == 5) {
|
||||
//设备 A1_TW_
|
||||
workorder.setDevice_code(col);
|
||||
}
|
||||
if (j == 9) {
|
||||
//单重
|
||||
BigDecimal bigDecimal = BigDecimal.valueOf(Double.parseDouble("#N/A".equals(col) ? "0.05" : col) * 1000);
|
||||
// workorder.setMaterial_weight(bigDecimal.setScale(3, RoundingMode.HALF_UP));
|
||||
}
|
||||
if(j == 10) {
|
||||
persons.add(col);
|
||||
workorder.setCurrent_produce_person_id(col);
|
||||
}
|
||||
if(j == 11) {
|
||||
workorder.setPlan_qty(new BigDecimal(Long.valueOf(col)));
|
||||
}
|
||||
if(j == 15) {
|
||||
workorder.setIs_needmove("是".equals(col) ? true : false);
|
||||
}
|
||||
if(j == 16) {
|
||||
workorder.setRemark(col);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(CollectionUtils.isEmpty(errorMap)) {
|
||||
data.add(workorder);
|
||||
}
|
||||
}
|
||||
List<MdMeMaterialbase> tmp_material_specs = materialbaseService.list(new QueryWrapper<MdMeMaterialbase>().in("material_spec", materialSpecs));
|
||||
List<SysUser> tmp_sysUsers = userService.list(new QueryWrapper<SysUser>().in("person_name", persons));
|
||||
List<PdmBiWorkprocedure> tmp_workprocedure_names = workprocedureService.list(new QueryWrapper<PdmBiWorkprocedure>().in("workprocedure_name", workprodures));
|
||||
Map<String,PdmBiWorkprocedure> collect = tmp_workprocedure_names.stream().collect(HashMap::new, (k, v) -> k.put(v.getWorkprocedure_name(), v), HashMap::putAll);
|
||||
Map<String,SysUser> users = tmp_sysUsers.stream().collect(HashMap::new, (k, v) -> k.put(v.getPerson_name(), v), HashMap::putAll);
|
||||
Map<String,List<MdMeMaterialbase>> materialspecs = tmp_material_specs.stream().collect(Collectors.groupingBy(MdMeMaterialbase::getMaterial_spec));
|
||||
for(int i = 0; i < data.size(); i++) {
|
||||
PdmProduceWorkorder workorder = data.get(i);
|
||||
SysUser sysUser = users.get(workorder.getCurrent_produce_person_id());
|
||||
if(sysUser == null) {
|
||||
//errorMap.put("第" + (i + 1) + "行:", "账号:" + workorder.getCurrent_produce_person_id() + "不存在");
|
||||
workorder.setCurrent_produce_person_id(null);
|
||||
}
|
||||
else{
|
||||
workorder.setCurrent_produce_person_id(sysUser.getUser_id());
|
||||
}
|
||||
PdmBiWorkprocedure workprocedure = collect.get(workorder.getWorkprocedure_id());
|
||||
if(workprocedure == null) {
|
||||
errorMap.put("第" + (i + 1) + "行:", "工序名称:" + workorder.getWorkprocedure_id() + "不存在");
|
||||
}
|
||||
else{
|
||||
workorder.setWorkprocedure_id(workprocedure.getWorkprocedure_id());
|
||||
}
|
||||
List<MdMeMaterialbase> mdMeMaterialbases = materialspecs.get(workorder.getMaterial_id());
|
||||
if(!CollectionUtils.isEmpty(mdMeMaterialbases)) {
|
||||
if(mdMeMaterialbases.size() == 1) {
|
||||
workorder.setMaterial_id(mdMeMaterialbases.get(0).getMaterial_id());
|
||||
if (j == 10) {
|
||||
persons.add(col);
|
||||
workorder.setCurrent_produce_person_id(col);
|
||||
}
|
||||
else{
|
||||
Optional<MdMeMaterialbase> first = mdMeMaterialbases.stream().filter(mdMeMaterialbase -> mdMeMaterialbase.getMaterial_code().contains("S") && Pattern.matches("^[0-9]*$", mdMeMaterialbase.getMaterial_name().substring(mdMeMaterialbase.getMaterial_name().length() - 1))).findFirst();
|
||||
if(first.isPresent()) {
|
||||
workorder.setMaterial_id(first.get().getMaterial_id());
|
||||
}
|
||||
else{
|
||||
errorMap.put("第" + (i + 1) + "行:", "物料规格:" + workorder.getMaterial_id() + "不存在");
|
||||
}
|
||||
if (j == 11) {
|
||||
workorder.setPlan_qty(new BigDecimal(Long.valueOf(col)));
|
||||
}
|
||||
}
|
||||
else{
|
||||
errorMap.put("第" + (i + 1) + "行:", "物料规格:" + workorder.getMaterial_id() + "不存在");
|
||||
}
|
||||
}
|
||||
if(!CollectionUtils.isEmpty(errorMap)) {
|
||||
throw new BadRequestException(JSON.toJSONString(errorMap));
|
||||
}
|
||||
else{
|
||||
List<String> workprocedures = data.stream().map(PdmProduceWorkorder::getWorkprocedure_id).collect(Collectors.toList());
|
||||
List<PdmBiDevice> list = deviceService.list(new QueryWrapper<PdmBiDevice>().in("workprocedure_id", workprocedures));
|
||||
Map<String,List<PdmBiDevice>> listMap = list.stream().collect(Collectors.groupingBy(PdmBiDevice::getWorkprocedure_id));
|
||||
for(int i = 0; i < data.size(); i++) {
|
||||
PdmProduceWorkorder item = data.get(i);
|
||||
List<PdmBiDevice> devices = listMap.get(item.getWorkprocedure_id());
|
||||
if (StringUtils.isNotEmpty(item.getDevice_code())){
|
||||
if("1535144356586165920".equals(item.getWorkprocedure_id())) {
|
||||
item.setDevice_code("A1_DC_" + item.getDevice_code().replaceAll("-", "_"));
|
||||
if (j == 15) {
|
||||
workorder.setIs_needmove("是".equals(col) ? true : false);
|
||||
}
|
||||
if (j == 16) {
|
||||
workorder.setRemark(col);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (CollectionUtils.isEmpty(errorMap)) {
|
||||
data.add(workorder);
|
||||
}
|
||||
}
|
||||
List<MdMeMaterialbase> tmp_material_specs = materialbaseService.list(new QueryWrapper<MdMeMaterialbase>().in("material_spec", materialSpecs));
|
||||
List<SysUser> tmp_sysUsers = userService.list(new QueryWrapper<SysUser>().in("person_name", persons));
|
||||
List<PdmBiWorkprocedure> tmp_workprocedure_names = workprocedureService.list(new QueryWrapper<PdmBiWorkprocedure>().in("workprocedure_name", workprodures));
|
||||
Map<String, PdmBiWorkprocedure> collect = tmp_workprocedure_names.stream().collect(HashMap::new, (k, v) -> k.put(v.getWorkprocedure_name(), v), HashMap::putAll);
|
||||
Map<String, SysUser> users = tmp_sysUsers.stream().collect(HashMap::new, (k, v) -> k.put(v.getPerson_name(), v), HashMap::putAll);
|
||||
Map<String, List<MdMeMaterialbase>> materialspecs = tmp_material_specs.stream().collect(Collectors.groupingBy(MdMeMaterialbase::getMaterial_spec));
|
||||
for (int i = 0; i < data.size(); i++) {
|
||||
PdmProduceWorkorder workorder = data.get(i);
|
||||
SysUser sysUser = users.get(workorder.getCurrent_produce_person_id());
|
||||
if (sysUser == null) {
|
||||
//errorMap.put("第" + (i + 1) + "行:", "账号:" + workorder.getCurrent_produce_person_id() + "不存在");
|
||||
workorder.setCurrent_produce_person_id(null);
|
||||
} else {
|
||||
workorder.setCurrent_produce_person_id(sysUser.getUser_id());
|
||||
}
|
||||
PdmBiWorkprocedure workprocedure = collect.get(workorder.getWorkprocedure_id());
|
||||
if (workprocedure == null) {
|
||||
errorMap.put("第" + (i + 1) + "行:", "工序名称:" + workorder.getWorkprocedure_id() + "不存在");
|
||||
} else {
|
||||
workorder.setWorkprocedure_id(workprocedure.getWorkprocedure_id());
|
||||
}
|
||||
List<MdMeMaterialbase> mdMeMaterialbases = materialspecs.get(workorder.getMaterial_id());
|
||||
if (!CollectionUtils.isEmpty(mdMeMaterialbases)) {
|
||||
if (mdMeMaterialbases.size() == 1) {
|
||||
workorder.setMaterial_id(mdMeMaterialbases.get(0).getMaterial_id());
|
||||
} else {
|
||||
Optional<MdMeMaterialbase> first = mdMeMaterialbases.stream().filter(mdMeMaterialbase -> mdMeMaterialbase.getMaterial_code().contains("S") && Pattern.matches("^[0-9]*$", mdMeMaterialbase.getMaterial_name().substring(mdMeMaterialbase.getMaterial_name().length() - 1))).findFirst();
|
||||
if (first.isPresent()) {
|
||||
workorder.setMaterial_id(first.get().getMaterial_id());
|
||||
} else {
|
||||
errorMap.put("第" + (i + 1) + "行:", "物料规格:" + workorder.getMaterial_id() + "不存在");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
errorMap.put("第" + (i + 1) + "行:", "物料规格:" + workorder.getMaterial_id() + "不存在");
|
||||
}
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(errorMap)) {
|
||||
throw new BadRequestException(JSON.toJSONString(errorMap));
|
||||
} else {
|
||||
List<String> workprocedures = data.stream().map(PdmProduceWorkorder::getWorkprocedure_id).collect(Collectors.toList());
|
||||
List<PdmBiDevice> list = deviceService.list(new QueryWrapper<PdmBiDevice>().in("workprocedure_id", workprocedures));
|
||||
Map<String, List<PdmBiDevice>> listMap = list.stream().collect(Collectors.groupingBy(PdmBiDevice::getWorkprocedure_id));
|
||||
for (int i = 0; i < data.size(); i++) {
|
||||
PdmProduceWorkorder item = data.get(i);
|
||||
List<PdmBiDevice> devices = listMap.get(item.getWorkprocedure_id());
|
||||
if (StringUtils.isNotEmpty(item.getDevice_code())) {
|
||||
if ("1535144356586165920".equals(item.getWorkprocedure_id())) {
|
||||
item.setDevice_code("A1_DC_" + item.getDevice_code().replaceAll("-", "_"));
|
||||
} else if ("1535143882327724032".equals(item.getWorkprocedure_id())) {
|
||||
item.setDevice_code("A1_XY_" + item.getDevice_code().replaceAll("-", "_"));
|
||||
} else {
|
||||
List<PdmBiDevice> deviceCollect = devices.stream().filter(pdmBiDevice -> {
|
||||
String device_code = pdmBiDevice.getDevice_code();
|
||||
int indexOf = device_code.lastIndexOf("_");
|
||||
String substring = device_code.substring(indexOf + 1);
|
||||
return Integer.valueOf(substring).equals(Integer.valueOf(item.getDevice_code()));
|
||||
}).collect(Collectors.toList());
|
||||
if (CollectionUtils.isEmpty(deviceCollect) || deviceCollect.size() > 1) {
|
||||
errorMap.put("第" + (i + 1) + "行:", "设备名称:" + item.getDevice_code() + "不存在了!!");
|
||||
} else {
|
||||
item.setDevice_code(deviceCollect.get(0).getDevice_code());
|
||||
}
|
||||
else if("1535143882327724032".equals(item.getWorkprocedure_id())) {
|
||||
item.setDevice_code("A1_XY_" + item.getDevice_code().replaceAll("-", "_"));
|
||||
}
|
||||
else{
|
||||
List<PdmBiDevice> deviceCollect = devices.stream().filter(pdmBiDevice ->
|
||||
{
|
||||
String device_code = pdmBiDevice.getDevice_code();
|
||||
int indexOf = device_code.lastIndexOf("_");
|
||||
String substring = device_code.substring(indexOf + 1);
|
||||
return Integer.valueOf(substring).equals(Integer.valueOf(item.getDevice_code()));
|
||||
}).collect(Collectors.toList());
|
||||
if(CollectionUtils.isEmpty(deviceCollect) || deviceCollect.size() > 1) {
|
||||
errorMap.put("第" + (i + 1) + "行:", "设备名称:" + item.getDevice_code() + "不存在了!!");
|
||||
}
|
||||
else{
|
||||
item.setDevice_code(deviceCollect.get(0).getDevice_code());
|
||||
}
|
||||
}
|
||||
}else {
|
||||
item.setDevice_code(null);
|
||||
}
|
||||
}
|
||||
if(!CollectionUtils.isEmpty(errorMap)) {
|
||||
throw new BadRequestException(JSON.toJSONString(errorMap));
|
||||
}
|
||||
else{
|
||||
this.saveBatch(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
item.setDevice_code(null);
|
||||
}
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(errorMap)) {
|
||||
throw new BadRequestException(JSON.toJSONString(errorMap));
|
||||
} else {
|
||||
this.saveBatch(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void packageForm(PdmProduceWorkorder workorder) {
|
||||
workorder.setWorkorder_id(IdUtil.getStringId());
|
||||
@@ -891,7 +885,7 @@ public class IPdmProduceWorkorderServiceImpl extends ServiceImpl<PdmProduceWorko
|
||||
workOrder.setUpdate_time(new Date());
|
||||
workOrder.setUpdate_id(SecurityUtils.getCurrentUserId());
|
||||
workOrder.setUpdate_name(SecurityUtils.getCurrentNickName());
|
||||
workOrder.setAps_realproducestart_date(getDates(workOrder.getPlanproducestart_date(),workOrder.getCreate_type().equals(StatusEnum.APSINTO.getCode())?"yyyy/MM/dd HH:mm:ss":"yyyy-MM-dd HH:mm:ss"));
|
||||
workOrder.setAps_realproducestart_date(getDates(workOrder.getPlanproducestart_date(), workOrder.getCreate_type().equals(StatusEnum.APSINTO.getCode()) ? "yyyy/MM/dd HH:mm:ss" : "yyyy-MM-dd HH:mm:ss"));
|
||||
workOrder.setRepare_qty(new BigDecimal(0));
|
||||
workOrder.setReal_qty(null);
|
||||
workOrder.setAps_assign_qty(workOrder.getPlan_qty());
|
||||
@@ -901,15 +895,11 @@ public class IPdmProduceWorkorderServiceImpl extends ServiceImpl<PdmProduceWorko
|
||||
if (workOrder.getWorkorder_id().indexOf(":") != workOrder.getWorkorder_id().lastIndexOf(":")) {
|
||||
String workOrderId = workOrder.getWorkorder_id().substring(0, workOrder.getWorkorder_id().indexOf(":", workOrder.getWorkorder_id().indexOf(":") + 1));
|
||||
|
||||
Optional<PdmProduceWorkorder> sonWorkOrder = Optional.ofNullable(getOne(new QueryWrapper<PdmProduceWorkorder>().lambda()
|
||||
.like(PdmProduceWorkorder::getWorkorder_id, workOrderId)
|
||||
.ne(PdmProduceWorkorder::getAps_work_type,"S")
|
||||
.orderByAsc(PdmProduceWorkorder::getPlanproducestart_date)
|
||||
.last("LIMIT 1")));
|
||||
Optional<PdmProduceWorkorder> sonWorkOrder = Optional.ofNullable(getOne(new QueryWrapper<PdmProduceWorkorder>().lambda().like(PdmProduceWorkorder::getWorkorder_id, workOrderId).ne(PdmProduceWorkorder::getAps_work_type, "S").orderByAsc(PdmProduceWorkorder::getPlanproducestart_date).last("LIMIT 1")));
|
||||
sonWorkOrder.ifPresent(workOrders -> {
|
||||
try {
|
||||
workOrders.setAps_assign_qty(workOrders.getPlan_qty());
|
||||
workOrders.setAps_realproducestart_date(getDates(workOrders.getPlanproducestart_date(),workOrders.getCreate_type().equals(StatusEnum.APSINTO.getCode())?"yyyy/MM/dd HH:mm:ss":"yyyy-MM-dd HH:mm:ss"));
|
||||
workOrders.setAps_realproducestart_date(getDates(workOrders.getPlanproducestart_date(), workOrders.getCreate_type().equals(StatusEnum.APSINTO.getCode()) ? "yyyy/MM/dd HH:mm:ss" : "yyyy-MM-dd HH:mm:ss"));
|
||||
workOrders.setUpdate_time(new Date());
|
||||
} catch (ParseException e) {
|
||||
throw new BadRequestException(e.getMessage());
|
||||
@@ -918,10 +908,7 @@ public class IPdmProduceWorkorderServiceImpl extends ServiceImpl<PdmProduceWorko
|
||||
|
||||
});
|
||||
//父工单强制指定需生产数量
|
||||
Optional<PdmProduceWorkorder> fatherWorkOrder = Optional.ofNullable(getOne(new QueryWrapper<PdmProduceWorkorder>().lambda()
|
||||
.like(PdmProduceWorkorder::getWorkorder_id, workOrderId)
|
||||
.eq(PdmProduceWorkorder::getAps_work_type,"S")
|
||||
.last("LIMIT 1")));
|
||||
Optional<PdmProduceWorkorder> fatherWorkOrder = Optional.ofNullable(getOne(new QueryWrapper<PdmProduceWorkorder>().lambda().like(PdmProduceWorkorder::getWorkorder_id, workOrderId).eq(PdmProduceWorkorder::getAps_work_type, "S").last("LIMIT 1")));
|
||||
fatherWorkOrder.ifPresent(workOrders -> {
|
||||
workOrders.setAps_assign_qty(workOrders.getPlan_qty());
|
||||
workOrders.setUpdate_time(new Date());
|
||||
@@ -965,32 +952,35 @@ public class IPdmProduceWorkorderServiceImpl extends ServiceImpl<PdmProduceWorko
|
||||
return workorderrecord;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private JSONObject packageForm(JSONObject param) {
|
||||
PdmProduceWorkorder workOrder = this.getOne(new QueryWrapper<PdmProduceWorkorder>().eq("workorder_id", param.getString("workorder_id")));
|
||||
JSONObject form = new JSONObject();
|
||||
MdMeMaterialbase material = materialbaseService.getOne(new QueryWrapper<MdMeMaterialbase>().eq("material_id", workOrder.getMaterial_id()));
|
||||
PdmBiDevice device = deviceService.getOne(new QueryWrapper<PdmBiDevice>().eq("device_code", workOrder.getDevice_code()));
|
||||
form.put("workorder_id", workOrder.getWorkorder_id());
|
||||
form.put("workorder_code", workOrder.getWorkorder_code());
|
||||
form.put("qty", workOrder.getPlan_qty());
|
||||
Integer limit_qty = material.getLimit_qty();
|
||||
form.put("outupperlimit_qty", limit_qty);
|
||||
if (limit_qty == null || limit_qty<1){
|
||||
form.put("outupperlimit_qty", device.getOutupperlimit_qty());
|
||||
}
|
||||
form.put("material_id", workOrder.getMaterial_id());
|
||||
form.put("material_name", material.getMaterial_name());
|
||||
form.put("material_code", material.getMaterial_code());
|
||||
form.put("material_spec", material.getMaterial_spec());
|
||||
form.put("device_code", workOrder.getDevice_code());
|
||||
form.put("is_needmove", workOrder.getIs_needmove() ? 1 : 0);
|
||||
form.put("package_ext", workOrder.getPackage_ext());
|
||||
if(param.containsKey("extra_map")) {
|
||||
form.put("extra_map", param.getJSONObject("extra_map"));
|
||||
}
|
||||
return form;
|
||||
}
|
||||
@NotNull
|
||||
private JSONObject packageForm(JSONObject param) {
|
||||
PdmProduceWorkorder workOrder = this.getOne(new QueryWrapper<PdmProduceWorkorder>().eq("workorder_id", param.getString("workorder_id")));
|
||||
JSONObject form = new JSONObject();
|
||||
MdMeMaterialbase material = materialbaseService.getOne(new QueryWrapper<MdMeMaterialbase>().eq("material_id", workOrder.getMaterial_id()));
|
||||
PdmBiDevice device = deviceService.getOne(new QueryWrapper<PdmBiDevice>().eq("device_code", workOrder.getDevice_code()));
|
||||
form.put("workorder_id", workOrder.getWorkorder_id());
|
||||
form.put("workorder_code", workOrder.getWorkorder_code());
|
||||
form.put("qty", workOrder.getPlan_qty());
|
||||
if (material == null) {
|
||||
throw new BadRequestException("物料信息不能为空!");
|
||||
}
|
||||
Integer limit_qty = material.getLimit_qty();
|
||||
form.put("outupperlimit_qty", limit_qty);
|
||||
if (limit_qty == null || limit_qty < 1) {
|
||||
form.put("outupperlimit_qty", device.getOutupperlimit_qty());
|
||||
}
|
||||
form.put("material_id", workOrder.getMaterial_id());
|
||||
form.put("material_name", material.getMaterial_name());
|
||||
form.put("material_code", material.getMaterial_code());
|
||||
form.put("material_spec", material.getMaterial_spec());
|
||||
form.put("device_code", workOrder.getDevice_code());
|
||||
form.put("is_needmove", workOrder.getIs_needmove() ? 1 : 0);
|
||||
form.put("package_ext", workOrder.getPackage_ext());
|
||||
if (param.containsKey("extra_map")) {
|
||||
form.put("extra_map", param.getJSONObject("extra_map"));
|
||||
}
|
||||
return form;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unqualReport(JSONObject param) {
|
||||
@@ -1013,8 +1003,7 @@ public class IPdmProduceWorkorderServiceImpl extends ServiceImpl<PdmProduceWorko
|
||||
Map<String, List<PdmProduceWorkorderrecord>> collect = workreportRecords.stream().collect(Collectors.groupingBy(PdmProduceWorkorderrecord::getWorkorder_id));
|
||||
for (Map.Entry<String, List<PdmProduceWorkorderrecord>> entry : collect.entrySet()) {
|
||||
List<PdmProduceWorkorderrecord> itemRecord = entry.getValue();
|
||||
itemRecord.forEach(item ->
|
||||
{
|
||||
itemRecord.forEach(item -> {
|
||||
item.setReport_status(ReportEnum.REPORT_STATUS.code("报工审核"));
|
||||
item.setConfirm_id(SecurityUtils.getCurrentUserId());
|
||||
item.setConfirm_name(SecurityUtils.getCurrentNickName());
|
||||
@@ -1074,8 +1063,7 @@ public class IPdmProduceWorkorderServiceImpl extends ServiceImpl<PdmProduceWorko
|
||||
}
|
||||
|
||||
@Override
|
||||
public void download(Map whereJson, HttpServletResponse response)
|
||||
throws IOException {
|
||||
public void download(Map whereJson, HttpServletResponse response) throws IOException {
|
||||
HashMap<String, String> map = new HashMap<>(whereJson);
|
||||
int i = 1;
|
||||
List<Map<String, Object>> excel_lst = new ArrayList<>();
|
||||
@@ -1196,8 +1184,7 @@ public class IPdmProduceWorkorderServiceImpl extends ServiceImpl<PdmProduceWorko
|
||||
List<Map> workOrders = pdmProduceWorkorderMapper.queryAdjustWorkOrder(query);
|
||||
List<Map> deviceCount = pdmProduceWorkorderMapper.queryDeviceCount(query);
|
||||
Map<String, String> deviceCountMap = deviceCount.stream().filter(item -> item.get("sale_id") != null).collect(Collectors.toMap(item -> item.get("sale_id").toString(), item -> item.get("device_count").toString()));
|
||||
workOrders.forEach(workOrder ->
|
||||
{
|
||||
workOrders.forEach(workOrder -> {
|
||||
if ("999".equals(workOrder.get("NO").toString())) {
|
||||
workOrder.put("num_sort", "999");
|
||||
workOrder.put("NO", "");
|
||||
@@ -1205,7 +1192,7 @@ public class IPdmProduceWorkorderServiceImpl extends ServiceImpl<PdmProduceWorko
|
||||
String saleId = (String) workOrder.get("sale_id");
|
||||
if (deviceCountMap.containsKey(saleId)) {
|
||||
workOrder.put("device_count", deviceCountMap.get(saleId));
|
||||
}else{
|
||||
} else {
|
||||
workOrder.put("device_count", "1");
|
||||
}
|
||||
|
||||
@@ -1217,12 +1204,21 @@ public class IPdmProduceWorkorderServiceImpl extends ServiceImpl<PdmProduceWorko
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Map> queryStatisticsSpec(WorkorderQuery query) {
|
||||
public List<Map> specOptionsSelect() {
|
||||
return pdmProduceWorkorderMapper.specOptionsSelect();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public TableDataInfo queryStatisticsSpec(WorkorderQuery query, PageQuery pageQuery) {
|
||||
Page<Object> page = PageHelper.startPage(pageQuery.getPage() + 1, pageQuery.getSize()).setOrderBy(pageQuery.getSort());
|
||||
List<Map> workOrders = pdmProduceWorkorderMapper.queryStatisticsSpec(query);
|
||||
if (!CollectionUtils.isEmpty(workOrders) && StringUtils.isNotBlank(query.getMaterial())) {
|
||||
workOrders = workOrders.stream().filter(map -> query.getMaterial().equals(map.get("material_spec"))).collect(Collectors.toList());
|
||||
}
|
||||
return workOrders;
|
||||
TableDataInfo build = TableDataInfo.build(workOrders);
|
||||
build.setTotalElements(page.getTotal());
|
||||
return build;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1248,13 +1244,15 @@ public class IPdmProduceWorkorderServiceImpl extends ServiceImpl<PdmProduceWorko
|
||||
public static List<Map<String, Object>> removeAdjacentDuplicates(List<Map> workOrders) {
|
||||
List<Map<String, Object>> result = new ArrayList<>();
|
||||
try {
|
||||
workOrders = workOrders.stream()
|
||||
.sorted(Comparator.comparing(m -> m.get("NO").toString()))
|
||||
.collect(Collectors.toList());
|
||||
workOrders = workOrders.stream().sorted(Comparator.comparing(m -> m.get("NO").toString())).collect(Collectors.toList());
|
||||
for (int i = 0; i < workOrders.size(); i++) {
|
||||
Map currentOrder = workOrders.get(i);
|
||||
if (i == 0 || !currentOrder.get("material_spec").equals(workOrders.get(i - 1).get("material_spec"))) {
|
||||
if (i == 0) {
|
||||
result.add(currentOrder);
|
||||
} else if (currentOrder.get("material_spec") != null && workOrders.get(i - 1).get("material_spec") != null) {
|
||||
if (!currentOrder.get("material_spec").equals(workOrders.get(i - 1).get("material_spec"))) {
|
||||
result.add(currentOrder);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (result.size() > 1) {
|
||||
@@ -1262,8 +1260,7 @@ public class IPdmProduceWorkorderServiceImpl extends ServiceImpl<PdmProduceWorko
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}catch (Exception e)
|
||||
{
|
||||
} catch (Exception e) {
|
||||
throw new BadRequestException(e.getMessage());
|
||||
}
|
||||
}
|
||||
@@ -1300,6 +1297,10 @@ public class IPdmProduceWorkorderServiceImpl extends ServiceImpl<PdmProduceWorko
|
||||
params.put("material_id", materialId);
|
||||
MpsSaleOrder mpsSaleOrder = mpsSaleOrderServiceImpl.getOne(new LambdaUpdateWrapper<MpsSaleOrder>().eq(MpsSaleOrder::getSale_id, saleId));
|
||||
if (mpsSaleOrder != null) {
|
||||
MdMeMaterialbase material = materialbaseService.getOne(new LambdaUpdateWrapper<MdMeMaterialbase>().eq(MdMeMaterialbase::getMaterial_id, materialId));
|
||||
if (material.getNet_weight() == null) {
|
||||
throw new BadRequestException("该物料规格无单重信息");
|
||||
}
|
||||
// 1. 订单正在生产的工单计划数量总和
|
||||
BigDecimal saleOrderWorkingQty = this.list(new LambdaUpdateWrapper<PdmProduceWorkorder>().eq(PdmProduceWorkorder::getSale_id, saleCode).eq(PdmProduceWorkorder::getWorkorder_status, WorkerOrderEnum.PRODUCTING.getCode())).stream().map(PdmProduceWorkorder::getPlan_qty).reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
// 2. 半成品库存数量冻结数 = 当前物料对应未开工的刻字工单计划数量总和(未开工包括创建,下发,暂停)
|
||||
@@ -1307,10 +1308,6 @@ public class IPdmProduceWorkorderServiceImpl extends ServiceImpl<PdmProduceWorko
|
||||
// 3. 半成品库存现存数量 = 当前物料对应半成品库库存总数(重量需转换成数量)
|
||||
List<Map> bcpInfo = iStIvtStructivtBcpService.getPdaBcpIvt(params);
|
||||
BigDecimal totalCanUseQty = bcpInfo.stream().map(item -> new BigDecimal(item.get("canuse_qty").toString())).reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
MdMeMaterialbase material = materialbaseService.getOne(new LambdaUpdateWrapper<MdMeMaterialbase>().eq(MdMeMaterialbase::getMaterial_id, materialId));
|
||||
if (material.getNet_weight() == null) {
|
||||
throw new BadRequestException("该物料规格无单重信息");
|
||||
}
|
||||
//半成品库存重量转换半成品数量
|
||||
BigDecimal totalBcpQty = totalCanUseQty.divide(material.getNet_weight(), 2, RoundingMode.HALF_UP);
|
||||
// 4. 订单待刻字数量=订单计划数量-已刻字数量-订单正在生产的工单计划数量总和
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
ALTER TABLE pdm_produce_workorder
|
||||
MODIFY COLUMN aps_workorder_no INT DEFAULT 999;
|
||||
UPDATE pdm_produce_workorder
|
||||
SET aps_workorder_no = 999;
|
||||
@@ -0,0 +1,114 @@
|
||||
<template>
|
||||
<el-dialog
|
||||
v-el-drag-dialog
|
||||
:close-on-click-modal="false"
|
||||
:visible.sync="querySpecVisible"
|
||||
class="edit-form"
|
||||
width="75%"
|
||||
>
|
||||
<div style="display: flex; flex-direction: column;">
|
||||
<el-card class="box-card" shadow="never">
|
||||
<el-form :inline="true" size="mini">
|
||||
<el-form-item label="规格:">
|
||||
<el-select
|
||||
v-model="query.material_id"
|
||||
class="filter-item"
|
||||
clearable
|
||||
filterable
|
||||
placeholder="选择规格"
|
||||
size="small"
|
||||
style="width: 220px"
|
||||
@change="materialSelectSpec(query.material_id)"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in selectSpecOptions"
|
||||
:key="item.material_id"
|
||||
:label="item.material_spec"
|
||||
:value="item.material_id"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-card>
|
||||
<div class="table-container" style="width: 100%">
|
||||
<el-table :data="crud.data">
|
||||
<el-table-column label="工序" prop="workprocedure_name"></el-table-column>
|
||||
<el-table-column label="规格" prop="material_spec"></el-table-column>
|
||||
<el-table-column label="计划开机数" prop="device_count"></el-table-column>
|
||||
<el-table-column label="开始生产时间" prop="start_time"></el-table-column>
|
||||
<el-table-column label="订单交期" prop="plandeliver_date"></el-table-column>
|
||||
<el-table-column label="工单号" prop="workorder_no"></el-table-column>
|
||||
<el-table-column label="工单数" prop="workorder_count"></el-table-column>
|
||||
<el-table-column label="生产总数" prop="plan_qty"></el-table-column>
|
||||
</el-table>
|
||||
<pagination/>
|
||||
</div>
|
||||
<div style="margin-bottom: 40px;"></div>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
import CRUD, { header, presenter } from '@crud/crud'
|
||||
import rrOperation from '@crud/RR.operation'
|
||||
import pagination from '@crud/Pagination'
|
||||
import crudProduceshiftorder from '@/views/wms/product_manage/workorder/produceshiftorder'
|
||||
|
||||
export default {
|
||||
name: 'SpecStatisticDialog',
|
||||
components: { rrOperation, pagination },
|
||||
cruds() {
|
||||
return CRUD({
|
||||
title: '规格统计',
|
||||
url: 'api/produceWorkorder/queryStatisticsSpec',
|
||||
sort: 'start_time',
|
||||
crudMethod: { ...crudProduceshiftorder },
|
||||
optShow: {}
|
||||
})
|
||||
},
|
||||
mixins: [presenter(), header()],
|
||||
data() {
|
||||
return {
|
||||
selectSpecOptions: [],
|
||||
material_spec: null,
|
||||
querySpecVisible: false
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.getSpecOptions()
|
||||
},
|
||||
methods: {
|
||||
async materialSelectSpec(material_id) {
|
||||
try {
|
||||
debugger
|
||||
console.log(material_id)
|
||||
this.crud.toQuery()
|
||||
} catch (err) {
|
||||
console.log(err)
|
||||
}
|
||||
},
|
||||
getSpecOptions() {
|
||||
debugger
|
||||
// 查询规格统计下拉框
|
||||
crudProduceshiftorder.specOptionsSelect().then(res => {
|
||||
this.selectSpecOptions = res.content
|
||||
})
|
||||
},
|
||||
async openQuerySpec() {
|
||||
try {
|
||||
this.crud.toQuery()
|
||||
this.querySpecVisible = true
|
||||
} catch (err) {
|
||||
console.log(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style lang="scss" rel="stylesheet/scss" scoped>
|
||||
::v-deep .el-dialog__body {
|
||||
padding-top: 0px;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -139,14 +139,13 @@
|
||||
</el-dialog>
|
||||
<!-- 规格弹窗 -->
|
||||
<el-dialog
|
||||
v-loading.fullscreen.lock="fullscreenLoading"
|
||||
:before-close="handleClose"
|
||||
:close-on-click-modal="false"
|
||||
:visible.sync="editSpecVisible"
|
||||
width="96%"
|
||||
>
|
||||
<div style="display: flex; height:800px;flex-direction: column;">
|
||||
|
||||
|
||||
<div style="display: flex; align-items: center;">
|
||||
<label style="margin-right: 10px;">规格:</label>
|
||||
<el-select
|
||||
@@ -299,6 +298,7 @@ export default {
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
fullscreenLoading: false,
|
||||
tabs: [
|
||||
{ label: '激光下料' },
|
||||
{ label: '旋压下料' },
|
||||
@@ -405,6 +405,7 @@ export default {
|
||||
},
|
||||
//规格提交
|
||||
submitTransfer() {
|
||||
this.fullscreenLoading = true
|
||||
const transferList = this.$refs.transfer.rightTableData
|
||||
const params = {
|
||||
'transferList': transferList,
|
||||
@@ -412,22 +413,23 @@ export default {
|
||||
tabIndex: this.tabIndex
|
||||
}
|
||||
crudProduceshiftorder.submitAdjustWorkOrder(params).then(res => {
|
||||
this.queryDeviceLists(this.tabIndex)
|
||||
//this.editSpecVisible = false
|
||||
this.fullscreenLoading = false
|
||||
this.$parent.success()
|
||||
this.openMaterialSpec(this.device_code_select, this.selectedValue, this.sort)
|
||||
this.queryDeviceLists(this.tabIndex)
|
||||
this.editSpecVisible = false
|
||||
//this.openMaterialSpec(this.device_code_select, this.selectedValue, this.sort)
|
||||
})
|
||||
},
|
||||
//点击规格
|
||||
async openMaterialSpec(deviceCode, selectedValue, sort) {
|
||||
try {
|
||||
debugger
|
||||
if (selectedValue !== '') {
|
||||
this.selectedValue = selectedValue
|
||||
}
|
||||
if (sort !== '') {
|
||||
this.sort = sort
|
||||
}
|
||||
this.fullscreenLoading = true
|
||||
const queryParam = { tabIndex: this.tabIndex }
|
||||
const res = await crudProduceshiftorder.queryAdjustWorkOrder(queryParam)
|
||||
const content = res.content
|
||||
@@ -437,13 +439,12 @@ export default {
|
||||
}
|
||||
return acc
|
||||
}, [])
|
||||
debugger
|
||||
if (selectedValue !== '' || this.sort !== '') {
|
||||
if (this.selectedValue !== '') {
|
||||
debugger
|
||||
this.editSpecVisible = true
|
||||
this.tableData1 = content.filter(item => item.material_spec === this.selectedValue).sort((a, b) => a[this.sort] - b[this.sort])
|
||||
this.$nextTick(() => {
|
||||
this.fullscreenLoading = false
|
||||
this.$refs.transfer.leftTableData = content.filter(item => item.material_spec === this.selectedValue).sort((a, b) => a[this.sort] - b[this.sort])
|
||||
this.$refs.transfer.$emit('initData', content.filter(item => item.NO !== 999 && item.device_code === this.device_code_select).sort((a, b) => a[this.sort] - b[this.sort]))
|
||||
})
|
||||
@@ -455,6 +456,7 @@ export default {
|
||||
this.editSpecVisible = true
|
||||
this.tableData1 = content.sort((a, b) => a[this.sort] - b[this.sort])
|
||||
this.$nextTick(() => {
|
||||
this.fullscreenLoading = false
|
||||
this.$refs.transfer.leftTableData = content.sort((a, b) => a[this.sort] - b[this.sort])
|
||||
this.$refs.transfer.$emit('initData', content.filter(item => item.NO !== 999 && item.device_code === this.device_code_select).sort((a, b) => a[this.sort] - b[this.sort]))
|
||||
})
|
||||
@@ -464,7 +466,7 @@ export default {
|
||||
this.$refs.transfer.pageSize = 20
|
||||
this.$refs.transfer.totalSize = this.tableData1.length
|
||||
} catch (err) {
|
||||
debugger
|
||||
this.fullscreenLoading = false
|
||||
console.log(err)
|
||||
}
|
||||
},
|
||||
@@ -568,26 +570,26 @@ export default {
|
||||
|
||||
//点击规格统计
|
||||
specStatistic() {
|
||||
this.queryMaterialSpec()
|
||||
// this.queryMaterialSpec()
|
||||
this.querySpecVisible = true
|
||||
},
|
||||
//点击规格统计
|
||||
async queryMaterialSpec() {
|
||||
try {
|
||||
const queryParam = { orderBy: 'start_time' }
|
||||
const res = await crudProduceshiftorder.queryStatisticsSpec(queryParam)
|
||||
const content = res.content
|
||||
this.materialSpecData = content
|
||||
this.selectSpecOptions = content.reduce((acc, currentItem) => {
|
||||
if (!acc.some(item => item.material_spec === currentItem.material_spec)) {
|
||||
acc.push(currentItem)
|
||||
}
|
||||
return acc
|
||||
}, [])
|
||||
} catch (err) {
|
||||
console.log(err)
|
||||
}
|
||||
},
|
||||
// async queryMaterialSpec() {
|
||||
// try {
|
||||
// const queryParam = { orderBy: 'start_time' }
|
||||
// const res = await crudProduceshiftorder.queryStatisticsSpec(queryParam)
|
||||
// const content = res.content
|
||||
// this.materialSpecData = content
|
||||
// this.selectSpecOptions = content.reduce((acc, currentItem) => {
|
||||
// if (!acc.some(item => item.material_spec === currentItem.material_spec)) {
|
||||
// acc.push(currentItem)
|
||||
// }
|
||||
// return acc
|
||||
// }, [])
|
||||
// } catch (err) {
|
||||
// console.log(err)
|
||||
// }
|
||||
// },
|
||||
//点击人员
|
||||
async openPersonButton(deviceCode) {
|
||||
this.device_code_select = deviceCode
|
||||
|
||||
@@ -172,11 +172,11 @@
|
||||
<template slot-scope="{ row }">
|
||||
<span
|
||||
:style="{
|
||||
color: row.aps_workorder_no === '999' || row.aps_workorder_no == '0' ? '' : 'orange',
|
||||
fontWeight: row.aps_workorder_no === '999' || row.aps_workorder_no == '0' ? 'normal' : 'bold'
|
||||
color: row.aps_workorder_no === 999 || row.aps_workorder_no == 0 ? '' : 'orange',
|
||||
fontWeight: row.aps_workorder_no === 999 || row.aps_workorder_no == 0 ? 'normal' : 'bold'
|
||||
}"
|
||||
>
|
||||
{{ row.aps_workorder_no === '999' || row.aps_workorder_no == '0' ? '未调整' : row.aps_workorder_no }}
|
||||
{{ row.aps_workorder_no === 999 || row.aps_workorder_no == 0 ? '未调整' : row.aps_workorder_no }}
|
||||
</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
@@ -276,51 +276,9 @@
|
||||
</el-table>
|
||||
<!--分页组件-->
|
||||
<pagination/>
|
||||
|
||||
<!-- 规格统计 -->
|
||||
<el-dialog
|
||||
v-el-drag-dialog
|
||||
:close-on-click-modal="false"
|
||||
:visible.sync="querySpecVisible"
|
||||
class="edit-form"
|
||||
width="75%"
|
||||
>
|
||||
<div style="display: flex; flex-direction: column;">
|
||||
<el-select
|
||||
v-model="material_spec"
|
||||
clearable
|
||||
filterable
|
||||
placeholder="选择规格"
|
||||
remote
|
||||
style="width: 140px; margin-bottom: 10px;margin-top: 10px;"
|
||||
@change="materialSelectSpec"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in selectSpecOptions"
|
||||
:key="item.material_spec"
|
||||
:label="item.material_spec"
|
||||
:value="item.material_spec"
|
||||
/>
|
||||
</el-select>
|
||||
<div class="table-container" style="width: 100%">
|
||||
<el-table :data="materialSpecData">
|
||||
<el-table-column label="工序" prop="workprocedure_name"></el-table-column>
|
||||
<el-table-column label="规格" prop="material_spec"></el-table-column>
|
||||
<el-table-column label="计划开机数" prop="device_count"></el-table-column>
|
||||
<el-table-column label="开始生产时间" prop="start_time"></el-table-column>
|
||||
<el-table-column label="订单交期" prop="plandeliver_date"></el-table-column>
|
||||
<el-table-column label="工单号" prop="workorder_no"></el-table-column>
|
||||
<el-table-column label="工单数" prop="workorder_count"></el-table-column>
|
||||
<el-table-column label="生产总数" prop="plan_qty"></el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
<div style="margin-bottom: 40px;"></div>
|
||||
</div>
|
||||
</el-dialog>
|
||||
|
||||
<SpecStatisticDialog ref="SpecStatisticDialog" :dialog-show.sync="querySpecVisible" @closeDialog="resetQuery"/>
|
||||
<!-- 排产调整弹窗 -->
|
||||
<adjustDialog ref="adjustDialog"/>
|
||||
|
||||
</div>
|
||||
<MaterDtl
|
||||
:dialog-show.sync="materialShow"
|
||||
@@ -364,6 +322,7 @@ import UploadDialog from '@/views/wms/product_manage/workorder/UploadDialog'
|
||||
import ReplaceDeviceDialog from '@/views/wms/product_manage/workorder/ReplaceDeviceDialog'
|
||||
import adjustDialog from '@/views/wms/product_manage/workorder/adjustDialog'
|
||||
import SaleOrder from '@/views/wms/pcs/saleorder/index.vue'
|
||||
import SpecStatisticDialog from '@/views/wms/product_manage/workorder/SpecStatisticDialog.vue'
|
||||
|
||||
const defaultForm = {
|
||||
workorder_id: null,
|
||||
@@ -406,6 +365,7 @@ const defaultForm = {
|
||||
export default {
|
||||
name: 'AdjustShiftorder',
|
||||
components: {
|
||||
SpecStatisticDialog,
|
||||
SaleOrder,
|
||||
AddDialog,
|
||||
pagination,
|
||||
@@ -523,11 +483,10 @@ export default {
|
||||
},
|
||||
//点击规格统计
|
||||
specStatistic() {
|
||||
this.queryMaterialSpec()
|
||||
this.querySpecVisible = true
|
||||
this.$refs.SpecStatisticDialog.openQuerySpec()
|
||||
},
|
||||
//点击规格统计
|
||||
async queryMaterialSpec() {
|
||||
async queryMaterialSpec1() {
|
||||
try {
|
||||
const queryParam = { orderBy: 'start_time' }
|
||||
const res = await crudProduceshiftorder.queryStatisticsSpec(queryParam)
|
||||
@@ -543,16 +502,6 @@ export default {
|
||||
console.log(err)
|
||||
}
|
||||
},
|
||||
//规格统计下拉框
|
||||
async materialSelectSpec(selectedValue) {
|
||||
const queryParam = { material: selectedValue, orderBy: 'start_time' }
|
||||
try {
|
||||
const res = await crudProduceshiftorder.queryStatisticsSpec(queryParam)
|
||||
this.materialSpecData = res.content
|
||||
} catch (err) {
|
||||
console.log(err)
|
||||
}
|
||||
},
|
||||
databaseUploadApi() {
|
||||
},
|
||||
changeEvent1(device) {
|
||||
@@ -783,6 +732,9 @@ export default {
|
||||
return true
|
||||
}
|
||||
},
|
||||
resetQuery() {
|
||||
this.crud.resetQuery()
|
||||
},
|
||||
// 新增编辑给form表单物料相关信息赋值
|
||||
setMaterValue(row) {
|
||||
debugger
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -217,11 +217,20 @@ export function getWorkOrderplanQty(data) {
|
||||
})
|
||||
}
|
||||
|
||||
export function specOptionsSelect(data) {
|
||||
return request({
|
||||
url: '/api/produceWorkorder/specOptionsSelect',
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
export default {
|
||||
add,
|
||||
addRows,
|
||||
edit,
|
||||
del,
|
||||
specOptionsSelect,
|
||||
submits,
|
||||
report,
|
||||
reportApprove,
|
||||
|
||||
Reference in New Issue
Block a user