mes报工

highway
zhaoxiaolin 1 year ago
parent ba999d484c
commit 96223a90a0

@ -31,8 +31,7 @@ public class DeviceTaskController {
*/ */
@PostMapping("/createSpotCheckPlanTask") @PostMapping("/createSpotCheckPlanTask")
public R createSpotCheckPlanTask() { public R createSpotCheckPlanTask() {
EquPlan equPlan = new EquPlan(); AjaxResult result = taskService.createSpotCheckPlanTask();
AjaxResult result = taskService.createSpotCheckPlanTask(equPlan);
if(result.isSuccess()){ if(result.isSuccess()){
return R.ok("点检计划生成成功"); return R.ok("点检计划生成成功");
} }

@ -150,6 +150,15 @@ public class EquOrder extends BaseEntity {
private int days; private int days;
private String equipmentName; private String equipmentName;
private String planRestrict;
public String getPlanRestrict() {
return planRestrict;
}
public void setPlanRestrict(String planRestrict) {
this.planRestrict = planRestrict;
}
public String getEquipmentName() { public String getEquipmentName() {
return equipmentName; return equipmentName;

@ -12,5 +12,5 @@ import com.op.device.domain.EquPlan;
*/ */
public interface IDeviceTaskService { public interface IDeviceTaskService {
AjaxResult createSpotCheckPlanTask(EquPlan equPlan); AjaxResult createSpotCheckPlanTask();
} }

@ -1,6 +1,8 @@
package com.op.device.service.impl; package com.op.device.service.impl;
import com.baomidou.dynamic.datasource.annotation.DS; import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder;
import com.op.common.core.domain.R;
import com.op.common.core.utils.DateUtils; import com.op.common.core.utils.DateUtils;
import com.op.common.core.utils.uuid.IdUtils; import com.op.common.core.utils.uuid.IdUtils;
import com.op.common.core.web.domain.AjaxResult; import com.op.common.core.web.domain.AjaxResult;
@ -8,6 +10,10 @@ import com.op.common.security.utils.SecurityUtils;
import com.op.device.domain.*; import com.op.device.domain.*;
import com.op.device.mapper.*; import com.op.device.mapper.*;
import com.op.device.service.IDeviceTaskService; import com.op.device.service.IDeviceTaskService;
import com.op.system.api.RemoteUserService;
import com.op.system.api.domain.SysUser;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -17,6 +23,11 @@ import org.springframework.util.CollectionUtils;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import static com.op.common.core.web.domain.AjaxResult.error; import static com.op.common.core.web.domain.AjaxResult.error;
import static com.op.common.core.web.domain.AjaxResult.success; import static com.op.common.core.web.domain.AjaxResult.success;
@ -29,6 +40,7 @@ import static com.op.common.core.web.domain.AjaxResult.success;
*/ */
@Service @Service
public class DeviceTaskServiceImpl implements IDeviceTaskService { public class DeviceTaskServiceImpl implements IDeviceTaskService {
protected Logger logger = LoggerFactory.getLogger(getClass());
@Autowired @Autowired
private DeviceTaskMapper deviceTaskMapper; private DeviceTaskMapper deviceTaskMapper;
@ -56,27 +68,60 @@ public class DeviceTaskServiceImpl implements IDeviceTaskService {
private EquPlanPersonMapper equPlanPersonMapper; private EquPlanPersonMapper equPlanPersonMapper;
@Autowired @Autowired
private EquOrderPersonMapper equOrderPersonMapper; private EquOrderPersonMapper equOrderPersonMapper;
@Autowired
private RemoteUserService remoteUserService;
/** /**
* *
* **/ * **/
@Override @Override
@DS("#header.poolName")
public AjaxResult createSpotCheckPlanTask(EquPlan equPlan) { public AjaxResult createSpotCheckPlanTask() {
// 加载sf-cloud库的sys_datasource
SysUser sysUser = new SysUser();
sysUser.setUserId(1L);
R<List<Map<String, String>>> dateSources0 = remoteUserService.getPoolNameList(sysUser);
List<Map<String, String>> dateSources = dateSources0.getData();
ExecutorService executorService = new ThreadPoolExecutor(
dateSources.size(),
dateSources.size(),
0L, TimeUnit.MILLISECONDS,
new LinkedBlockingQueue<Runnable>());
try {
dateSources.forEach(dateSource -> {
if("ds_1000".equals(dateSource.get("poolName"))){//TODO生产去掉
logger.info("++++++++++++" + dateSource.get("poolName") + "++++点检开始++++++++++");
Runnable run = () -> createSpotCheckPlanFunc(dateSource.get("poolName"));
executorService.execute(run);
}
});
} catch (Exception e) {
logger.error("service == dataClearTask == exception", e);
return error("service == dataClearTask == exception");
} finally {
executorService.shutdown();
}
return success();
}
public void createSpotCheckPlanFunc(String poolName){
DynamicDataSourceContextHolder.push(poolName);// 这是数据源的key
/**equ_plan equ_plan_equ**/ /**equ_plan equ_plan_equ**/
EquPlan equPlan = new EquPlan();
equPlan.setPlanType("spotInspection"); equPlan.setPlanType("spotInspection");
List<EquPlan> plans = deviceTaskMapper.getPlans(equPlan); List<EquPlan> plans = deviceTaskMapper.getPlans(equPlan);
for(EquPlan plan:plans){ for(EquPlan plan:plans){
EquOrder hasTask = deviceTaskMapper.getNewTaskOrder(plan); EquOrder hasTask = deviceTaskMapper.getNewTaskOrder(plan);
if(hasTask==null || Integer.parseInt(plan.getPlanLoop())<= hasTask.getDays()){ if(hasTask==null || Integer.parseInt(plan.getPlanLoop())<= hasTask.getDays()){
//生成点检计划 //生成点检计划
int m = this.createSpotCheckPlan(plan); int m = this.createSpotCheckPlan(plan);
if(m==0){ if(m==0){
error("equ_order相关添加失败"); error("equ_order相关添加失败");
} }
} }
} }
logger.info("++++++++++++" + poolName + "++++点检结束++++++++++");
return success();
} }
private int createSpotCheckPlan(EquPlan plan){ private int createSpotCheckPlan(EquPlan plan){
@ -96,6 +141,7 @@ public class DeviceTaskServiceImpl implements IDeviceTaskService {
order.setOrderCode(orderCode); order.setOrderCode(orderCode);
/**equ_order**/ /**equ_order**/
sce = equOrderMapper.insertEquOrder(order); sce = equOrderMapper.insertEquOrder(order);
System.out.println("========equ_order:"+sce);
/**equ_plan_equ->equ_order_equ*************************************************************/ /**equ_plan_equ->equ_order_equ*************************************************************/
EquPlanEqu equPlanEqu = new EquPlanEqu(); EquPlanEqu equPlanEqu = new EquPlanEqu();
@ -114,6 +160,7 @@ public class DeviceTaskServiceImpl implements IDeviceTaskService {
equ.setCode(orderCode); equ.setCode(orderCode);
} }
sce = equOrderEquMapper.insertEquOrderEqus(equs); sce = equOrderEquMapper.insertEquOrderEqus(equs);
System.out.println("========equ_order_equ:"+sce);
/**equ_plan_detail->equ_order_detail*******************************************************/ /**equ_plan_detail->equ_order_detail*******************************************************/
EquPlanDetail itqo = new EquPlanDetail(); EquPlanDetail itqo = new EquPlanDetail();
itqo.setParentCode(plan.getPlanEquId()); itqo.setParentCode(plan.getPlanEquId());
@ -148,12 +195,14 @@ public class DeviceTaskServiceImpl implements IDeviceTaskService {
itme.setParentCode(orderEquId); itme.setParentCode(orderEquId);
} }
sce = equOrderDetailMapper.insertEquOrderDetails(details); sce = equOrderDetailMapper.insertEquOrderDetails(details);
System.out.println("========equ_order_detail:"+sce);
/**equ_plan_standard->equ_order_standard*******************************************************/ /**equ_plan_standard->equ_order_standard*******************************************************/
if(CollectionUtils.isEmpty(standards)){ if(CollectionUtils.isEmpty(standards)){
return 0; return 0;
} }
sce = equOrderStandardMapper.insertEquOrderStandards(standards); sce = equOrderStandardMapper.insertEquOrderStandards(standards);
/**equ_plan_person->equ_order_person*********************************************************/ System.out.println("========equ_order_detail:"+sce);
/**equ_plan_person->equ_order_standard*********************************************************/
EquPlanPerson equPlanPerson = new EquPlanPerson(); EquPlanPerson equPlanPerson = new EquPlanPerson();
equPlanPerson.setPlanCode(plan.getPlanCode()); equPlanPerson.setPlanCode(plan.getPlanCode());
List<EquPlanPerson> persons = equPlanPersonMapper.selectEquPlanPersonList(equPlanPerson); List<EquPlanPerson> persons = equPlanPersonMapper.selectEquPlanPersonList(equPlanPerson);
@ -169,6 +218,7 @@ public class DeviceTaskServiceImpl implements IDeviceTaskService {
person.setPlanCode(orderCode); person.setPlanCode(orderCode);
} }
sce = equOrderPersonMapper.insertEquOrderPlans(persons); sce = equOrderPersonMapper.insertEquOrderPlans(persons);
System.out.println("========equ_order_standard:"+sce);
return sce; return sce;
} }
} }

@ -177,6 +177,8 @@
<if test="repairCode != null">repair_code,</if> <if test="repairCode != null">repair_code,</if>
<if test="repairCode != null">repair_code,</if> <if test="repairCode != null">repair_code,</if>
<if test="workCode != null">work_code,</if> <if test="workCode != null">work_code,</if>
<if test="planRestrict != null">plan_restrict,</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="orderId != null">#{orderId},</if> <if test="orderId != null">#{orderId},</if>
@ -213,6 +215,7 @@
<if test="orderInspect != null">#{orderInspect},</if> <if test="orderInspect != null">#{orderInspect},</if>
<if test="repairCode != null">#{repairCode},</if> <if test="repairCode != null">#{repairCode},</if>
<if test="workCode != null">#{workCode},</if> <if test="workCode != null">#{workCode},</if>
<if test="planRestrict != null">#{planRestrict},</if>
</trim> </trim>
</insert> </insert>

@ -93,6 +93,9 @@ public class MesReportWork extends BaseEntity {
@Excel(name = "工时") @Excel(name = "工时")
private Long workTime; private Long workTime;
@Excel(name = "用人")
private Long useMan;
/** 线体编码 */ /** 线体编码 */
@Excel(name = "线体编码") @Excel(name = "线体编码")
private String machineCode; private String machineCode;
@ -161,6 +164,14 @@ public class MesReportWork extends BaseEntity {
private String feedbackTimeStart; private String feedbackTimeStart;
private String feedbackTimeEnd; private String feedbackTimeEnd;
public Long getUseMan() {
return useMan;
}
public void setUseMan(Long useMan) {
this.useMan = useMan;
}
public BigDecimal getQuantitySplit() { public BigDecimal getQuantitySplit() {
return quantitySplit; return quantitySplit;
} }

@ -25,6 +25,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="status" column="status" /> <result property="status" column="status" />
<result property="remark" column="remark" /> <result property="remark" column="remark" />
<result property="workTime" column="work_time" /> <result property="workTime" column="work_time" />
<result property="useMan" column="use_man" />
<result property="machineCode" column="machine_code" /> <result property="machineCode" column="machine_code" />
<result property="machineName" column="machine_name" /> <result property="machineName" column="machine_name" />
<result property="teamCode" column="team_code" /> <result property="teamCode" column="team_code" />
@ -95,6 +96,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
mrw.feedback_time, mrw.record_user, mrw.status, mrw.remark, mrw.work_time, mrw.machine_code, mrw.feedback_time, mrw.record_user, mrw.status, mrw.remark, mrw.work_time, mrw.machine_code,
mrw.machine_name, mrw.team_code, mrw.shift_code, mrw.create_by, mrw.machine_name, mrw.team_code, mrw.shift_code, mrw.create_by,
mrw.create_time,mrw.upload_time,mrw.upload_status,mrw.upload_msg, mrw.create_time,mrw.upload_time,mrw.upload_status,mrw.upload_msg,
mrw.use_man,
pow.order_code,pow.quantity_split pow.order_code,pow.quantity_split
from mes_report_work mrw from mes_report_work mrw
left join pro_order_workorder pow on mrw.workorder_code = pow.workorder_code left join pro_order_workorder pow on mrw.workorder_code = pow.workorder_code
@ -455,6 +457,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="status != null">status,</if> <if test="status != null">status,</if>
<if test="remark != null">remark,</if> <if test="remark != null">remark,</if>
<if test="workTime != null">work_time,</if> <if test="workTime != null">work_time,</if>
<if test="useMan != null">use_man,</if>
<if test="machineCode != null">machine_code,</if> <if test="machineCode != null">machine_code,</if>
<if test="machineName != null">machine_name,</if> <if test="machineName != null">machine_name,</if>
<if test="teamCode != null">team_code,</if> <if test="teamCode != null">team_code,</if>
@ -490,6 +493,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="status != null">#{status},</if> <if test="status != null">#{status},</if>
<if test="remark != null">#{remark},</if> <if test="remark != null">#{remark},</if>
<if test="workTime != null">#{workTime},</if> <if test="workTime != null">#{workTime},</if>
<if test="useMan != null">#{useMan},</if>
<if test="machineCode != null">#{machineCode},</if> <if test="machineCode != null">#{machineCode},</if>
<if test="machineName != null">#{machineName},</if> <if test="machineName != null">#{machineName},</if>
<if test="teamCode != null">#{teamCode},</if> <if test="teamCode != null">#{teamCode},</if>
@ -528,6 +532,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="status != null">status = #{status},</if> <if test="status != null">status = #{status},</if>
<if test="remark != null">remark = #{remark},</if> <if test="remark != null">remark = #{remark},</if>
<if test="workTime != null">work_time = #{workTime},</if> <if test="workTime != null">work_time = #{workTime},</if>
<if test="useMan != null">use_man = #{useMan},</if>
<if test="machineCode != null">machine_code = #{machineCode},</if> <if test="machineCode != null">machine_code = #{machineCode},</if>
<if test="machineName != null">machine_name = #{machineName},</if> <if test="machineName != null">machine_name = #{machineName},</if>
<if test="teamCode != null">team_code = #{teamCode},</if> <if test="teamCode != null">team_code = #{teamCode},</if>

Loading…
Cancel
Save