优化
This commit is contained in:
@@ -94,6 +94,14 @@ public class ProducetaskController {
|
|||||||
producetaskprocService.submit2(whereJson);
|
producetaskprocService.submit2(whereJson);
|
||||||
return new ResponseEntity<>(HttpStatus.OK);
|
return new ResponseEntity<>(HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Log("提交")
|
||||||
|
@ApiOperation("提交")
|
||||||
|
@PostMapping("/submit22")
|
||||||
|
public ResponseEntity<Object> submit22(@RequestBody JSONObject whereJson) {
|
||||||
|
producetaskprocService.submit22(whereJson);
|
||||||
|
return new ResponseEntity<>(HttpStatus.OK);
|
||||||
|
}
|
||||||
@Log("提交")
|
@Log("提交")
|
||||||
@ApiOperation("提交")
|
@ApiOperation("提交")
|
||||||
@PostMapping("/submit3")
|
@PostMapping("/submit3")
|
||||||
|
|||||||
@@ -82,6 +82,11 @@ public interface ProducetaskprocService {
|
|||||||
* @param whereJson /
|
* @param whereJson /
|
||||||
*/
|
*/
|
||||||
void submit2(JSONObject whereJson);
|
void submit2(JSONObject whereJson);
|
||||||
|
/**
|
||||||
|
* 提交
|
||||||
|
* @param whereJson /
|
||||||
|
*/
|
||||||
|
void submit22(JSONObject whereJson);
|
||||||
/**
|
/**
|
||||||
* 提交
|
* 提交
|
||||||
* @param whereJson /
|
* @param whereJson /
|
||||||
|
|||||||
@@ -891,6 +891,167 @@ public class ProducetaskprocServiceImpl implements ProducetaskprocService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public void submit22(JSONObject form) {
|
||||||
|
Long currentUserId = SecurityUtils.getCurrentUserId();
|
||||||
|
String nickName = SecurityUtils.getNickName();
|
||||||
|
String now = DateUtil.now();
|
||||||
|
WQLObject PCS_IF_ProductPlanProc = WQLObject.getWQLObject("PCS_IF_ProductPlanProc");
|
||||||
|
WQLObject MPS_BD_CapacityTemplateSeries = WQLObject.getWQLObject("MPS_BD_CapacityTemplateSeries");
|
||||||
|
JSONArray ja = form.getJSONArray("rows");
|
||||||
|
JSONObject json = form.getJSONObject("query");
|
||||||
|
String captemplate_id = json.getString("captemplate_id");
|
||||||
|
if (StrUtil.isEmpty(captemplate_id)) {
|
||||||
|
throw new BadRequestException("排产模板不能为空!");
|
||||||
|
}
|
||||||
|
//根据交期、理化时间及工厂日历往前推工作日,得到各月计划结束日期
|
||||||
|
JSONArray new_ja = new JSONArray();
|
||||||
|
for (int i = 0; i < ja.size(); i++) {
|
||||||
|
JSONObject jo = ja.getJSONObject(i);
|
||||||
|
String device_id = jo.getString("device_id");
|
||||||
|
String is_proc = jo.getString("is_proc");
|
||||||
|
if (!"1".equals(is_proc)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (StrUtil.isEmpty(device_id)) {
|
||||||
|
throw new BadRequestException("关键设备不能为空!");
|
||||||
|
}
|
||||||
|
int report_time = jo.getInteger("report_time");
|
||||||
|
String plan_finish_date = jo.getString("plan_finish_date");
|
||||||
|
Date date = DateUtil.parse(plan_finish_date);
|
||||||
|
|
||||||
|
int report_day = (int) Math.ceil(report_time/24.0);
|
||||||
|
Date date2 = DateUtil.offsetDay(date, -report_day);
|
||||||
|
String plan_finish_date2 = DateUtil.formatDate(date2);
|
||||||
|
JSONObject last_day = WQL.getWO("QPDM_PRODUCTPLANPROC")
|
||||||
|
.addParam("flag", "9")
|
||||||
|
.addParam("planstart_date", plan_finish_date2)
|
||||||
|
.addParam("device_id", jo.getString("device_id"))
|
||||||
|
.process()
|
||||||
|
.uniqueResult(0);
|
||||||
|
if(last_day ==null){
|
||||||
|
throw new BadRequestException("未配置"+plan_finish_date2+"前的工作日历!");
|
||||||
|
}
|
||||||
|
jo.put("plan_finish_date2",last_day.getString("factory_date"));
|
||||||
|
new_ja.add(jo);
|
||||||
|
}
|
||||||
|
|
||||||
|
for(int i=0;i<new_ja.size();i++){
|
||||||
|
JSONObject jo = new_ja.getJSONObject(i);
|
||||||
|
JSONObject series = MPS_BD_CapacityTemplateSeries.query("captemplate_id='"+captemplate_id+"' and product_series_id='"+jo.getString("product_series")+"'").uniqueResult(0);
|
||||||
|
if(series ==null){
|
||||||
|
throw new BadRequestException("系列模板产能未配置!");
|
||||||
|
}
|
||||||
|
String device_id = jo.getString("device_id");
|
||||||
|
String plan_finish_date2 = jo.getString("plan_finish_date2");
|
||||||
|
Date plan_finish_date = DateUtil.parse(plan_finish_date2);
|
||||||
|
double fact_weight = jo.getDouble("fact_weight");
|
||||||
|
double standard_weight = jo.getDouble("standard_weight");
|
||||||
|
//批次数量
|
||||||
|
int pcsn_num = (int) Math.ceil(fact_weight/standard_weight);
|
||||||
|
//当前系列最大产能批次
|
||||||
|
int totalproducecapacity_qty = series.getInteger("totalproducecapacity_qty");
|
||||||
|
//生产日数
|
||||||
|
int days = this.getDays(jo.getString("material_id"));
|
||||||
|
//计算最后一天的开始日期
|
||||||
|
Date planstart_date = DateUtil.offsetDay(plan_finish_date,-(days-1));
|
||||||
|
JSONObject last_day = WQL.getWO("QPDM_PRODUCTPLANPROC")
|
||||||
|
.addParam("flag", "9")
|
||||||
|
.addParam("planstart_date", DateUtil.formatDate(planstart_date))
|
||||||
|
.addParam("device_id", device_id)
|
||||||
|
.process()
|
||||||
|
.uniqueResult(0);
|
||||||
|
if(last_day ==null){
|
||||||
|
throw new BadRequestException("未配置"+DateUtil.formatDate(planstart_date)+"前的工作日历!");
|
||||||
|
}
|
||||||
|
String start_date = last_day.getString("factory_date");
|
||||||
|
planstart_date = DateUtil.parse(start_date);
|
||||||
|
//若总批次大于一日批次数
|
||||||
|
if(pcsn_num > totalproducecapacity_qty){
|
||||||
|
while(pcsn_num > 0){
|
||||||
|
//取余
|
||||||
|
int yu = pcsn_num%totalproducecapacity_qty;
|
||||||
|
if(yu > 0){
|
||||||
|
jo.put("planstart_date",start_date);
|
||||||
|
Date planend_date = DateUtil.offsetDay(planstart_date,days-1);
|
||||||
|
jo.put("planend_date",DateUtil.formatDate(planend_date));
|
||||||
|
jo.put("workorder_type","01");
|
||||||
|
jo.put("product_weight",standard_weight*yu);
|
||||||
|
jo.put("product_num",yu);
|
||||||
|
jo.put("product_series_id",jo.getString("product_series"));
|
||||||
|
this.createDay(jo);
|
||||||
|
//当前开始日期前的一个工作日为下一个开始日期
|
||||||
|
JSONObject before_day = WQL.getWO("QPDM_PRODUCTPLANPROC")
|
||||||
|
.addParam("flag", "10")
|
||||||
|
.addParam("planstart_date", start_date)
|
||||||
|
.addParam("device_id", device_id)
|
||||||
|
.process()
|
||||||
|
.uniqueResult(0);
|
||||||
|
if(before_day ==null){
|
||||||
|
throw new BadRequestException("未配置"+start_date+"前的工作日历!");
|
||||||
|
}
|
||||||
|
//更新参数
|
||||||
|
start_date = before_day.getString("factory_date");
|
||||||
|
planstart_date = DateUtil.parse(start_date);
|
||||||
|
pcsn_num = pcsn_num - yu;
|
||||||
|
fact_weight = fact_weight - yu*standard_weight;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
jo.put("planstart_date",start_date);
|
||||||
|
//重新计算结束日期
|
||||||
|
Date planend_date = DateUtil.offsetDay(planstart_date,days-1);
|
||||||
|
jo.put("planend_date",DateUtil.formatDate(planend_date));
|
||||||
|
jo.put("workorder_type","01");
|
||||||
|
jo.put("product_weight",standard_weight*totalproducecapacity_qty);
|
||||||
|
jo.put("product_num",totalproducecapacity_qty);
|
||||||
|
jo.put("product_series_id",jo.getString("product_series"));
|
||||||
|
this.createDay(jo);
|
||||||
|
//当前开始日期前的一个工作日为下一个开始日期
|
||||||
|
JSONObject before_day = WQL.getWO("QPDM_PRODUCTPLANPROC")
|
||||||
|
.addParam("flag", "10")
|
||||||
|
.addParam("planstart_date", start_date)
|
||||||
|
.addParam("device_id", device_id)
|
||||||
|
.process()
|
||||||
|
.uniqueResult(0);
|
||||||
|
if(before_day ==null){
|
||||||
|
throw new BadRequestException("未配置"+start_date+"前的工作日历!");
|
||||||
|
}
|
||||||
|
//更新参数
|
||||||
|
start_date = before_day.getString("factory_date");
|
||||||
|
planstart_date = DateUtil.parse(start_date);
|
||||||
|
pcsn_num = pcsn_num - totalproducecapacity_qty;
|
||||||
|
fact_weight = fact_weight - totalproducecapacity_qty*standard_weight;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
jo.put("planstart_date",start_date);
|
||||||
|
Date planend_date = DateUtil.offsetDay(planstart_date,days-1);
|
||||||
|
jo.put("planend_date",DateUtil.formatDate(planend_date));
|
||||||
|
jo.put("workorder_type","01");
|
||||||
|
jo.put("product_weight",fact_weight);
|
||||||
|
jo.put("product_num",pcsn_num);
|
||||||
|
jo.put("product_series_id",jo.getString("product_series"));
|
||||||
|
this.createDay(jo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < new_ja.size(); i++) {
|
||||||
|
JSONObject jo = new_ja.getJSONObject(i);
|
||||||
|
JSONObject jsonMst = PCS_IF_ProductPlanProc.query("plan_id ='" + jo.getString("plan_id") + "' and is_proc = '1'").uniqueResult(0);
|
||||||
|
if (jsonMst == null) {
|
||||||
|
throw new BadRequestException(jo.getString("task_code")+"当前记录状态异常,操作失败!");
|
||||||
|
}
|
||||||
|
HashMap<String, String> map = new HashMap<>();
|
||||||
|
map.put("is_proc", "2");
|
||||||
|
map.put("update_optid", currentUserId + "");
|
||||||
|
map.put("update_optname", nickName);
|
||||||
|
map.put("update_time", now);
|
||||||
|
PCS_IF_ProductPlanProc.update(map, "plan_id ='" + jo.getString("plan_id") + "'");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JSONArray getDevices(Map json) {
|
public JSONArray getDevices(Map json) {
|
||||||
HashMap<String, String> map = new HashMap<>(json);
|
HashMap<String, String> map = new HashMap<>(json);
|
||||||
@@ -934,7 +1095,6 @@ public class ProducetaskprocServiceImpl implements ProducetaskprocService {
|
|||||||
Long currentUserId = SecurityUtils.getCurrentUserId();
|
Long currentUserId = SecurityUtils.getCurrentUserId();
|
||||||
String nickName = SecurityUtils.getNickName();
|
String nickName = SecurityUtils.getNickName();
|
||||||
String now = DateUtil.now();
|
String now = DateUtil.now();
|
||||||
JwtUserDto currentUser = (JwtUserDto) SecurityUtils.getCurrentUser();
|
|
||||||
WQLObject pdm_bi_productdeptpcsn = WQLObject.getWQLObject("pdm_bi_productdeptpcsn");
|
WQLObject pdm_bi_productdeptpcsn = WQLObject.getWQLObject("pdm_bi_productdeptpcsn");
|
||||||
WQLObject MPS_BD_ProductDailyPlan = WQLObject.getWQLObject("MPS_BD_ProductDailyPlan");
|
WQLObject MPS_BD_ProductDailyPlan = WQLObject.getWQLObject("MPS_BD_ProductDailyPlan");
|
||||||
JSONObject new_jo = new JSONObject();
|
JSONObject new_jo = new JSONObject();
|
||||||
|
|||||||
@@ -96,6 +96,7 @@
|
|||||||
pp.*,
|
pp.*,
|
||||||
ext.old_mark,
|
ext.old_mark,
|
||||||
ext.standard_mark,
|
ext.standard_mark,
|
||||||
|
ext.report_time,
|
||||||
ext.standard_weight_pft AS standard_weight,
|
ext.standard_weight_pft AS standard_weight,
|
||||||
materialbase.material_type_id,
|
materialbase.material_type_id,
|
||||||
ext.product_series,
|
ext.product_series,
|
||||||
@@ -278,5 +279,55 @@
|
|||||||
ENDQUERY
|
ENDQUERY
|
||||||
ENDIF
|
ENDIF
|
||||||
|
|
||||||
|
IF 输入.flag = "9"
|
||||||
|
QUERY
|
||||||
|
SELECT
|
||||||
|
FactoryCalendarDtl.factorycalendardtl_id,
|
||||||
|
FactoryCalendarDtl.factory_date,
|
||||||
|
FactoryCalendarDtl.work_type
|
||||||
|
FROM
|
||||||
|
PDM_BI_FactoryCalendarDtl FactoryCalendarDtl
|
||||||
|
LEFT JOIN PDM_BI_FactoryCalendar FactoryCalendar ON FactoryCalendar.factorycalendar_id = FactoryCalendarDtl.factorycalendar_id
|
||||||
|
WHERE
|
||||||
|
1 = 1
|
||||||
|
and FactoryCalendar.is_delete='0'
|
||||||
|
and FactoryCalendar.is_active ='1'
|
||||||
|
and FactoryCalendarDtl.work_type='00'
|
||||||
|
OPTION 输入.planstart_date <> ""
|
||||||
|
FactoryCalendarDtl.factory_date <= 输入.planstart_date
|
||||||
|
ENDOPTION
|
||||||
|
OPTION 输入.device_id <> ""
|
||||||
|
FactoryCalendar.device_id = 输入.device_id
|
||||||
|
ENDOPTION
|
||||||
|
ORDER BY FactoryCalendarDtl.factory_date desc
|
||||||
|
ENDSELECT
|
||||||
|
ENDQUERY
|
||||||
|
ENDIF
|
||||||
|
|
||||||
|
IF 输入.flag = "10"
|
||||||
|
QUERY
|
||||||
|
SELECT
|
||||||
|
FactoryCalendarDtl.factorycalendardtl_id,
|
||||||
|
FactoryCalendarDtl.factory_date,
|
||||||
|
FactoryCalendarDtl.work_type
|
||||||
|
FROM
|
||||||
|
PDM_BI_FactoryCalendarDtl FactoryCalendarDtl
|
||||||
|
LEFT JOIN PDM_BI_FactoryCalendar FactoryCalendar ON FactoryCalendar.factorycalendar_id = FactoryCalendarDtl.factorycalendar_id
|
||||||
|
WHERE
|
||||||
|
1 = 1
|
||||||
|
and FactoryCalendar.is_delete='0'
|
||||||
|
and FactoryCalendar.is_active ='1'
|
||||||
|
and FactoryCalendarDtl.work_type='00'
|
||||||
|
OPTION 输入.planstart_date <> ""
|
||||||
|
FactoryCalendarDtl.factory_date < 输入.planstart_date
|
||||||
|
ENDOPTION
|
||||||
|
OPTION 输入.device_id <> ""
|
||||||
|
FactoryCalendar.device_id = 输入.device_id
|
||||||
|
ENDOPTION
|
||||||
|
ORDER BY FactoryCalendarDtl.factory_date desc
|
||||||
|
ENDSELECT
|
||||||
|
ENDQUERY
|
||||||
|
ENDIF
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -55,6 +55,14 @@ export function submit2(data) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function submit22(data) {
|
||||||
|
return request({
|
||||||
|
url: 'api/producetask/submit22',
|
||||||
|
method: 'post',
|
||||||
|
data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
export function getDevices(params) {
|
export function getDevices(params) {
|
||||||
return request({
|
return request({
|
||||||
url: 'api/producetask/getDevices',
|
url: 'api/producetask/getDevices',
|
||||||
@@ -70,4 +78,4 @@ export function getCapacitytes(params) {
|
|||||||
params
|
params
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
export default { add, edit, del, importExcel, getCapacitytes, submit, getDevices, submit2, submit3 }
|
export default { add, edit, del, importExcel, getCapacitytes, submit, getDevices, submit2, submit3, submit22 }
|
||||||
|
|||||||
@@ -150,6 +150,16 @@
|
|||||||
>
|
>
|
||||||
预排
|
预排
|
||||||
</el-button>
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
slot="right"
|
||||||
|
class="filter-item"
|
||||||
|
type="primary"
|
||||||
|
icon="el-icon-position"
|
||||||
|
size="mini"
|
||||||
|
@click="save2()"
|
||||||
|
>
|
||||||
|
按交期预排
|
||||||
|
</el-button>
|
||||||
</crudOperation>
|
</crudOperation>
|
||||||
|
|
||||||
<!--表格渲染-->
|
<!--表格渲染-->
|
||||||
@@ -330,6 +340,25 @@ export default {
|
|||||||
this.crud.loading = false
|
this.crud.loading = false
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
save2() {
|
||||||
|
if(this.crud.query.captemplate_id === '' || this.crud.query.captemplate_id === undefined ){
|
||||||
|
this.crud.notify('请先选择排产模板!')
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
this.checkrows = this.$refs.table.selection
|
||||||
|
if(this.checkrows.length === 0 ){
|
||||||
|
this.crud.notify('请勾选需要操作的记录!')
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
this.crud.loading = true
|
||||||
|
producetask.submit22({ query: this.crud.query, rows: this.checkrows}).then(res => {
|
||||||
|
this.crud.notify('操作成功!')
|
||||||
|
this.crud.loading = false
|
||||||
|
this.querytable()
|
||||||
|
}).catch(() => {
|
||||||
|
this.crud.loading = false
|
||||||
|
})
|
||||||
|
},
|
||||||
querytable() {
|
querytable() {
|
||||||
this.crud.toQuery()
|
this.crud.toQuery()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user