This commit is contained in:
zds
2022-11-20 21:40:59 +08:00
parent 1918282cf5
commit 1cc0f75c6f
19 changed files with 594 additions and 80 deletions

View File

@@ -88,4 +88,7 @@ public class ProductplanprocDto implements Serializable {
/** 任务号 */
private String task_code;
/** 导入人 */
private Long device_id;
}

View File

@@ -94,6 +94,13 @@ public class ProducetaskController {
producetaskprocService.submit2(whereJson);
return new ResponseEntity<>(HttpStatus.OK);
}
@Log("提交")
@ApiOperation("提交")
@PostMapping("/submit3")
public ResponseEntity<Object> submit3(@RequestBody JSONObject whereJson) {
producetaskprocService.submit3(whereJson);
return new ResponseEntity<>(HttpStatus.OK);
}
@Log("导入月计划excel")
@ApiOperation("导入月计划excel")
@PostMapping({"/importExcel/{bomtype}"})

View File

@@ -82,6 +82,11 @@ public interface ProducetaskprocService {
* @param whereJson /
*/
void submit2(JSONObject whereJson);
/**
* 提交
* @param whereJson /
*/
void submit3(JSONObject whereJson);
/**
* 提交

View File

@@ -272,8 +272,17 @@ public class DailyplanServiceImpl implements DailyplanService {
Date date = DateUtil.parse(planstart_date);
int days = this.getDays(json.getString("material_id"));
Date planend_date = DateUtil.offsetDay(date,days-1);
json.put("planend_date",DateUtil.formatDate(planend_date));
String planend_time = DateUtil.formatDate(planend_date).substring(0,10);
JSONObject last_day = WQL.getWO("QPDM_PRODUCTPLANPROC")
.addParam("flag", "7")
.addParam("planstart_date", planend_time)
.addParam("device_id", json.getString("device_id"))
.process()
.uniqueResult(0);
if(last_day ==null){
throw new BadRequestException("未配置"+planend_time+"后的工作日历!");
}
json.put("planend_date",last_day.getString("factory_date"));
JSONObject mater = MD_ME_ProducMaterialExt.query("material_id='"+json.getString("material_id")+"'").uniqueResult(0);
double standard_weight = mater.getDouble("standard_weight_pft");
@@ -314,7 +323,17 @@ public class DailyplanServiceImpl implements DailyplanService {
Date date = DateUtil.parse(planstart_date);
int days = this.getDays(whereJson.getString("material_id"));
Date planend_date = DateUtil.offsetDay(date,days-1);
whereJson.put("planend_date",DateUtil.formatDate(planend_date));
String planend_time = DateUtil.formatDate(planend_date).substring(0,10);
JSONObject last_day = WQL.getWO("QPDM_PRODUCTPLANPROC")
.addParam("flag", "7")
.addParam("planstart_date", planend_time)
.addParam("device_id", whereJson.getString("device_id"))
.process()
.uniqueResult(0);
if(last_day ==null){
throw new BadRequestException("未配置"+planend_time+"后的工作日历!");
}
whereJson.put("planend_date",last_day.getString("factory_date"));
JSONObject mater = MD_ME_ProducMaterialExt.query("material_id='"+whereJson.getString("material_id")+"'").uniqueResult(0);
double standard_weight = mater.getDouble("standard_weight_pft");
@@ -609,6 +628,7 @@ public class DailyplanServiceImpl implements DailyplanService {
JSONObject last_day = WQL.getWO("QPDM_PRODUCTPLANPROC")
.addParam("flag", "7")
.addParam("planstart_date", planstart_date)
.addParam("device_id", jo.getString("device_id"))
.process()
.uniqueResult(0);
if(last_day ==null){
@@ -618,7 +638,18 @@ public class DailyplanServiceImpl implements DailyplanService {
int days = this.getDays(jo.getString("material_id"));
Date start_date = DateUtil.parse(planstart_date);
Date planend_date = DateUtil.offsetDay(start_date,days-1);
jo.put("planend_date",DateUtil.formatDate(planend_date));
String str_planend_date = DateUtil.formatDate(planend_date);
JSONObject last_planend_date = WQL.getWO("QPDM_PRODUCTPLANPROC")
.addParam("flag", "7")
.addParam("planstart_date", str_planend_date.substring(0,10))
.addParam("device_id", jo.getString("device_id"))
.process()
.uniqueResult(0);
if(last_planend_date == null){
throw new BadRequestException("未配置"+str_planend_date.substring(0,10)+"后的工作日历!");
}
jo.put("planend_date", last_planend_date.getString("factory_date"));
JSONArray lasts = WQL.getWO("QPDM_PRODUCTPLANPROC")
.addParam("flag", "8")
.addParam("device_id", jo.getString("device_id"))
@@ -684,7 +715,16 @@ public class DailyplanServiceImpl implements DailyplanService {
new_jo.put("product_series_id", json.getString("product_series_id"));
new_jo.put("device_id", json.getString("device_id"));
new_jo.put("planstart_date", json.getString("planstart_date"));
new_jo.put("planend_date", json.getString("planend_date"));
JSONObject last_day = WQL.getWO("QPDM_PRODUCTPLANPROC")
.addParam("flag", "7")
.addParam("planstart_date", json.getString("planend_date"))
.addParam("device_id", json.getString("device_id"))
.process()
.uniqueResult(0);
if(last_day ==null){
throw new BadRequestException("未配置"+json.getString("planend_date")+"后的工作日历!");
}
new_jo.put("planend_date", last_day.getString("factory_date"));
new_jo.put("remark", json.getString("remark"));

View File

@@ -44,7 +44,7 @@ public class FactoryCalendarServiceImpl implements FactoryCalendarService {
@Override
public Map<String, Object> queryAll(Map whereJson, Pageable page) {
String search = MapUtil.getStr(whereJson, "search");
HashMap<String, String> map = new HashMap<>();
HashMap<String, String> map = new HashMap<>(whereJson);
map.put("flag", "1");
if (StrUtil.isNotEmpty(search)) map.put("search", "%" + search + "%");
@@ -171,9 +171,9 @@ public class FactoryCalendarServiceImpl implements FactoryCalendarService {
String is_active = whereJson.getString("is_active");
if (is_active.equals("1")) {
//查询是否存在已经启用的日历
JSONObject mst = WQLObject.getWQLObject("PDM_BI_FactoryCalendar").query("is_active = '1' AND is_delete = '0'").uniqueResult(0);
JSONObject mst = WQLObject.getWQLObject("PDM_BI_FactoryCalendar").query("is_active = '1' AND is_delete = '0' and device_id='"+whereJson.getString("device_id")+"'").uniqueResult(0);
if (ObjectUtil.isNotEmpty(mst)) {
throw new PdaRequestException("工厂日历只能启用一个!");
throw new PdaRequestException("同一个设备工厂日历只能启用一个!");
}
}
WQLObject.getWQLObject("PDM_BI_FactoryCalendar").update(whereJson);

View File

@@ -185,7 +185,17 @@ public class ProducetaskprocServiceImpl implements ProducetaskprocService {
procTab.delete(jsonProc);
}
}
@Override
@Transactional(rollbackFor = Exception.class)
public void submit3(JSONObject json) {
WQLObject procTab = WQLObject.getWQLObject("pcs_if_productplanproc");
JSONObject jsonProc = procTab.query("plan_id = '" + json.getString("plan_id") + "'").uniqueResult(0);
if(StrUtil.equals(jsonProc.getString("is_proc"), "2")){
throw new BadRequestException("排产状态,不可修改");
}
jsonProc.put("device_id",json.getString("device_id"));
procTab.update(jsonProc);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void submit(JSONObject json) {
@@ -217,6 +227,8 @@ public class ProducetaskprocServiceImpl implements ProducetaskprocService {
WQLObject planProcTab = WQLObject.getWQLObject("pcs_if_productplanproc");
WQLObject materTab = WQLObject.getWQLObject("md_me_materialbase");
WQLObject em_bi_deviceinfo = WQLObject.getWQLObject("em_bi_deviceinfo");
WQLObject MD_ME_ProducMaterialExt = WQLObject.getWQLObject("MD_ME_ProducMaterialExt");
JSONObject json = WQL.getWO("QPCS_IF_PRODUCTPLANPROC02").addParam("flag", "1").addParam("id", id).process().uniqueResult(0);
//根据路径获取表格里的记录
String path = json.getString("path");
@@ -230,7 +242,7 @@ public class ProducetaskprocServiceImpl implements ProducetaskprocService {
String plan_org_code = String.valueOf(map.get(2));
String plan_org_name = String.valueOf(map.get(3));
String material_code = String.valueOf(map.get(4));
String product_type_name = String.valueOf(map.get(5));
String device_code = String.valueOf(map.get(5));
Long product_weight = Long.valueOf((String) map.get(6));
String plan_finish_date = String.valueOf(map.get(7));
String remark = String.valueOf(map.get(8));
@@ -255,7 +267,6 @@ public class ProducetaskprocServiceImpl implements ProducetaskprocService {
dto.setMaterial_code(material_code);
dto.setMaterial_name(jsonMater.getString("material_name"));
dto.setMaterial_spec(jsonMater.getString("material_spec"));
dto.setProduct_type_name(product_type_name);
MaterialbaseDto materDto = materialbaseService.findById(jsonMater.getLong
("material_id"));
@@ -276,6 +287,24 @@ public class ProducetaskprocServiceImpl implements ProducetaskprocService {
dto.setUpdate_optname(SecurityUtils.getNickName());
dto.setUpdate_time(DateUtil.now());
dto.setRemark(remark);
if(StrUtil.isNotEmpty(device_code) && !"null".equals(device_code)){
JSONObject device = em_bi_deviceinfo.query("is_delete='0' and is_active='1' and device_code='"+device_code+"'").uniqueResult(0);
if(device!=null){
dto.setDevice_id(device.getLong("device_id"));
}
}else{
JSONObject jsonMater2 = MD_ME_ProducMaterialExt.query("material_id = '" + jsonMater.getString("material_id") + "'").uniqueResult(0);
if (ObjectUtil.isEmpty(jsonMater2)) {
throw new BadRequestException("此【" + material_code + "】物料未配置成品物料扩展信息");
}
String product_series = jsonMater2.getString("product_series");
if(StrUtil.isNotEmpty(product_series)){
JSONObject device = WQL.getWO("QPDM_PRODUCTPLANPROC").addParam("flag", "33").addParam("product_series", product_series).process().uniqueResult(0);
if(device!=null){
dto.setDevice_id(device.getLong("id"));
}
}
}
dto.setTask_code(CodeUtil.getNewCode("PCS_TASK_CODE"));
//判断表里有没有此条记录
JSONObject jsonObject = planProcTab.query("plan_org_code = '" + plan_org_code + "' and plan_month = '" + plan_month + "' and material_code ='" + material_code + "' and plan_finish_date='"+plan_finish_date+"'").uniqueResult(0);
@@ -786,6 +815,7 @@ public class ProducetaskprocServiceImpl implements ProducetaskprocService {
JSONObject last_day = WQL.getWO("QPDM_PRODUCTPLANPROC")
.addParam("flag", "7")
.addParam("planstart_date", planstart_date)
.addParam("device_id", jo.getString("device_id"))
.process()
.uniqueResult(0);
if(last_day ==null){
@@ -795,7 +825,18 @@ public class ProducetaskprocServiceImpl implements ProducetaskprocService {
int days = this.getDays(jo.getString("material_id"));
Date start_date = DateUtil.parse(planstart_date);
Date planend_date = DateUtil.offsetDay(start_date,days-1);
jo.put("planend_date",DateUtil.formatDate(planend_date));
String str_planend_date = DateUtil.formatDate(planend_date);
JSONObject last_planend_date = WQL.getWO("QPDM_PRODUCTPLANPROC")
.addParam("flag", "7")
.addParam("planstart_date", str_planend_date.substring(0,10))
.addParam("device_id", jo.getString("device_id"))
.process()
.uniqueResult(0);
if(last_planend_date == null){
throw new BadRequestException("未配置"+str_planend_date.substring(0,10)+"后的工作日历!");
}
jo.put("planend_date", last_planend_date.getString("factory_date"));
JSONArray lasts = WQL.getWO("QPDM_PRODUCTPLANPROC")
.addParam("flag", "8")
.addParam("device_id", jo.getString("device_id"))
@@ -900,7 +941,17 @@ public class ProducetaskprocServiceImpl implements ProducetaskprocService {
new_jo.put("product_series_id", json.getString("product_series_id"));
new_jo.put("device_id", json.getString("device_id"));
new_jo.put("planstart_date", json.getString("planstart_date"));
new_jo.put("planend_date", json.getString("planend_date"));
JSONObject last_day = WQL.getWO("QPDM_PRODUCTPLANPROC")
.addParam("flag", "7")
.addParam("planstart_date", json.getString("planend_date"))
.addParam("device_id", json.getString("device_id"))
.process()
.uniqueResult(0);
if(last_day ==null){
throw new BadRequestException("未配置"+json.getString("planend_date")+"后的工作日历!");
}
new_jo.put("planend_date", last_day.getString("factory_date"));
new_jo.put("remark", json.getString("remark"));

View File

@@ -132,7 +132,16 @@ public class WorkOrderServiceImpl implements WorkOrdereService {
int days = this.getDays(json.getString("material_id"));
Date planend_date = DateUtil.offsetDay(date,days-1);
String planend_time = DateUtil.formatDate(planend_date).substring(0,10);
json.put("planend_time",planend_time+" 23:59:59");
JSONObject last_day = WQL.getWO("QPDM_PRODUCTPLANPROC")
.addParam("flag", "7")
.addParam("planstart_date", planend_time)
.addParam("device_id", json.getString("device_id"))
.process()
.uniqueResult(0);
if(last_day ==null){
throw new BadRequestException("未配置"+planend_time+"后的工作日历!");
}
json.put("planend_time",last_day.getString("factory_date")+" 23:59:59");
mstTab.insert(json);
this.updatePcsn(json);
}
@@ -178,7 +187,16 @@ public class WorkOrderServiceImpl implements WorkOrdereService {
int days = this.getDays(whereJson.getString("material_id"));
Date planend_date = DateUtil.offsetDay(date,days-1);
String planend_time = DateUtil.formatDate(planend_date).substring(0,10);
whereJson.put("planend_time",planend_time+" 23:59:59");
JSONObject last_day = WQL.getWO("QPDM_PRODUCTPLANPROC")
.addParam("flag", "7")
.addParam("planstart_date", planend_time)
.addParam("device_id", whereJson.getString("device_id"))
.process()
.uniqueResult(0);
if(last_day ==null){
throw new BadRequestException("未配置"+planend_time+"后的工作日历!");
}
whereJson.put("planend_time",last_day.getString("factory_date")+" 23:59:59");
mstTab.update(whereJson);
}
@@ -275,11 +293,7 @@ public class WorkOrderServiceImpl implements WorkOrdereService {
WQLObject em_bi_deviceinfo = WQLObject.getWQLObject("em_bi_deviceinfo");
WQLObject wo_param = WQLObject.getWQLObject("sys_param");
JSONArray ja = json.getJSONArray("rows");
JSONArray calendar = pdm_bi_factorycalendar.query("is_active='1' and is_delete = '0'").getResultJSONArray(0);
if(calendar.size()!=1){
throw new BadRequestException("未设置满足条件的的日历!");
}
String factorycalendar_id = calendar.getJSONObject(0).getString("factorycalendar_id");
for (int i = 0; i < ja.size(); i++) {
JSONObject jo = ja.getJSONObject(i);
@@ -288,6 +302,12 @@ public class WorkOrderServiceImpl implements WorkOrdereService {
throw new BadRequestException(jo.getString("workorder_code") + "当前工令记录状态异常,操作失败!");
}
String jo_device_id = jsonMst.getString("device_id");
JSONObject calendar = pdm_bi_factorycalendar.query("is_active='1' and is_delete = '0' and device_id='"+jo_device_id+"'").uniqueResult(0);
if(calendar == null){
throw new BadRequestException("当前设备未设置满足条件的的日历!");
}
String factorycalendar_id = calendar.getString("factorycalendar_id");
JSONObject Formula = PDM_BI_Formula.query("workorder_id ='" + jo.getString("workorder_id") + "' and is_delete = '0' and is_audit='0' ").uniqueResult(0);
if (Formula != null) {
throw new BadRequestException(jo.getString("workorder_code") + "工令对应配方未审核,操作失败!");
@@ -462,14 +482,38 @@ public class WorkOrderServiceImpl implements WorkOrdereService {
//是否有工序任务
if(late_task==null){//没有
if(devices.size()>0){
device_id = devices.getJSONObject(0).getString("device_id");
JSONObject device = em_bi_deviceinfo.query("device_id='"+device_id+"'").uniqueResult(0);
if(device!=null){
planstart_time = planstart_date+" "+device.getString("honor_time");
JSONObject last_day = WQL.getWO("QPDM_PRODUCTPLANPROC")
.addParam("flag", "7")
.addParam("planstart_date", planstart_date)
.addParam("device_id", device_id)
.process()
.uniqueResult(0);
if(last_day ==null){
throw new BadRequestException("未配置"+planstart_date+"后的工作日历!");
}
planstart_time = last_day.getString("factory_date")+" "+device.getString("honor_time");
}
}
}else{//有
planstart_time = late_task.getString("planend_time");
planstart_date = planstart_time.substring(0,10);
JSONObject last_day = WQL.getWO("QPDM_PRODUCTPLANPROC")
.addParam("flag", "7")
.addParam("planstart_date", planstart_date)
.addParam("device_id", device_id)
.process()
.uniqueResult(0);
if(last_day ==null){
throw new BadRequestException("未配置"+planstart_date+"后的工作日历!");
}
if(!planstart_date.equals(last_day.getString("factory_date"))){
JSONObject device = em_bi_deviceinfo.query("device_id='"+device_id+"'").uniqueResult(0);
if(device!=null){
planstart_time = last_day.getString("factory_date")+" "+device.getString("honor_time");
}
}
}
}
}else if("GX008".equals(workprocedure_code)) {//压团制粒工序
@@ -506,7 +550,6 @@ public class WorkOrderServiceImpl implements WorkOrdereService {
}
}
Date date = DateUtil.parse(planstart_time);
// DateTime newDate1 = DateUtil.offsetHour(date, routedtl.getInteger("plan_time"));
jsonMst.put("planstart_time", date.toString());
routedtl.put("planstart_time", date.toString());
@@ -514,6 +557,20 @@ public class WorkOrderServiceImpl implements WorkOrdereService {
DateTime newDate2 = DateUtil.offsetHour(date, routedtl.getInteger("product_time"));
jsonMst.put("planend_time", newDate2.toString());
routedtl.put("planend_time",newDate2.toString());
if("GX003".equals(workprocedure_code)) {//喷雾工序
JSONObject last_day = WQL.getWO("QPDM_PRODUCTPLANPROC")
.addParam("flag", "7")
.addParam("planstart_date", newDate2.toString().substring(0, 10))
.addParam("device_id", device_id)
.process()
.uniqueResult(0);
if(last_day ==null){
throw new BadRequestException("未配置"+newDate2.toString().substring(0, 10)+"后的工作日历!");
}
newDate2 = DateUtil.parse(last_day.getString("factory_date")+" "+newDate2.toString().substring(11));
jsonMst.put("planend_time", newDate2.toString());
routedtl.put("planend_time",newDate2.toString());
}
routeBefore = routedtl;
if ((j + 1) < routeDtls.size()) {//非最后一道工序
JSONObject routeNext = routeDtls.getJSONObject(j + 1);

View File

@@ -16,6 +16,7 @@
输入.flag TYPEAS s_string
输入.search TYPEAS s_string
输入.processroute_code TYPEAS s_string
输入.device_id TYPEAS s_string
[临时表]
@@ -44,6 +45,7 @@
PAGEQUERY
SELECT
dar.*,
device.device_name,
dept.NAME,
(
case when dar.is_active = '0' then '否'
@@ -51,11 +53,15 @@
FROM
pdm_bi_factorycalendar dar
LEFT JOIN sys_dept dept ON dar.org_id = dept.dept_id
LEFT JOIN em_bi_deviceinfo device ON device.device_id = dar.device_id
WHERE
dar.is_delete = '0'
OPTION 输入.search <> ""
(dar.factorycalendar_code like 输入.search or
dar.factorycalendar_name like 输入.search)
ENDOPTION
OPTION 输入.device_id <> ""
device.device_id = 输入.device_id
ENDOPTION
ENDSELECT
ENDPAGEQUERY

View File

@@ -56,10 +56,12 @@
pp.*,
ext.old_mark,
ext.standard_mark,
ext.standard_weight_pft AS standard_weight
ext.standard_weight_pft AS standard_weight,
deviceinfo.device_name
FROM
PCS_IF_ProductPlanProc pp
LEFT JOIN MD_ME_ProducMaterialExt ext ON pp.material_id = ext.material_id
LEFT JOIN em_bi_deviceinfo deviceinfo ON deviceinfo.device_id = pp.device_id
WHERE
1=1
OPTION 输入.is_proc <> ""
@@ -80,6 +82,9 @@
OPTION 输入.plan_org_code <> ""
pp.plan_org_code = 输入.plan_org_code
ENDOPTION
OPTION 输入.device_id <> ""
pp.device_id = 输入.device_id
ENDOPTION
ENDSELECT
ENDPAGEQUERY
ENDIF
@@ -93,30 +98,12 @@
ext.standard_weight_pft AS standard_weight,
materialbase.material_type_id,
ext.product_series,
deviceinfo.device_id,
deviceinfo.device_name
FROM
PCS_IF_ProductPlanProc pp
LEFT JOIN md_me_materialbase materialbase ON pp.material_id = materialbase.material_id
LEFT JOIN MD_ME_ProducMaterialExt ext ON pp.material_id = ext.material_id
INNER JOIN (
SELECT
WorkDevice.workprocedure_id,
WorkDevice.product_series_id,
WorkDevice.captemplate_id,
MAX( WorkDevice.device_id ) AS device_id
FROM
MPS_BD_CapacityTemplateWorkDevice WorkDevice
WHERE
1 = 1
AND WorkDevice.captemplate_id = '1534741977764073472'
AND WorkDevice.workprocedure_id = '1472449923327856640'
GROUP BY
WorkDevice.workprocedure_id,
WorkDevice.product_series_id,
WorkDevice.captemplate_id
) WorkDevice2 ON concat( ext.product_series ) = concat( WorkDevice2.product_series_id )
LEFT JOIN em_bi_deviceinfo deviceinfo ON deviceinfo.device_id = WorkDevice2.device_id
LEFT JOIN em_bi_deviceinfo deviceinfo ON deviceinfo.device_id = pp.device_id
WHERE
1 = 1
AND pp.is_proc IN ( '1', '2' )
@@ -124,7 +111,7 @@
pp.is_proc = 输入.is_proc
ENDOPTION
OPTION 输入.device_id <> ""
deviceinfo.device_id = 输入.device_id
pp.device_id = 输入.device_id
ENDOPTION
OPTION 输入.plan_month <> ""
pp.plan_month = 输入.plan_month
@@ -185,6 +172,7 @@
OPTION 输入.product_series <> ""
WorkDevice.product_series_id = 输入.product_series
ENDOPTION
order by deviceinfo.device_code asc
ENDSELECT
ENDQUERY
ENDIF
@@ -260,6 +248,9 @@
OPTION 输入.planstart_date <> ""
FactoryCalendarDtl.factory_date >= 输入.planstart_date
ENDOPTION
OPTION 输入.device_id <> ""
FactoryCalendar.device_id = 输入.device_id
ENDOPTION
ORDER BY FactoryCalendarDtl.factory_date
ENDSELECT
ENDQUERY