Commit a7bf6e5c authored by 李驰骋's avatar 李驰骋

Merge remote-tracking branch 'origin/dev' into dev

parents 9ec3b853 63fdb315
......@@ -257,6 +257,7 @@ public class ProTaskController extends BaseController {
ExceptionUtil.checkTrueThrowException(StringUtils.isNull(proTaskVo.getScheduleStartDate()), MessageUtils.message("pro.schedule.error.not.null.startTime"));
ExceptionUtil.checkTrueThrowException(StringUtils.isNull(proTaskVo.getDuration()) || proTaskVo.getDuration() <= 0L, MessageUtils.message("pro.schedule.limit.min.duration"));
ExceptionUtil.checkTrueThrowException(StringUtils.isNull(proTaskVo.getWorkunitId()), MessageUtils.message("md.workUnit.error.not.null"));
ExceptionUtil.checkTrueThrowException(StringUtils.isNull(proTaskVo.getTaskWorkunit()) || StringUtils.isNull(proTaskVo.getTaskWorkunit().getWorkunitId()), MessageUtils.message("md.workUnit.error.not.null"));
ExceptionUtil.checkTrueThrowException(proTaskVo.getQuantity().compareTo(BigDecimal.ZERO) != 1, MessageUtils.message("pro.schedule.limit.min.quantity"));
......
......@@ -159,4 +159,12 @@ public class ProTaskWorkunitController extends BaseController {
return AjaxResult.success("获取成功",printData);
}
@ApiOperation("获取工序打印日记")
@Log(title = "获取工序打印日记", businessType = BusinessType.UPDATE)
@PostMapping(value= "/printDataBySpil")
public AjaxResult printDataBySpil(@RequestBody Long taskWorkunitId) {
Map<String,Object> printData = proTaskWorkunitService.printDataBySpil(taskWorkunitId);
return AjaxResult.success("获取成功",printData);
}
}
......@@ -29,7 +29,8 @@ public class ProTaskWorkunit extends BaseEntity {
@TableId
@ApiModelProperty("生产任务ID")
private Long taskWorkunitId;
@ApiModelProperty("被拆分的生产任务ID")
private Long sourceTaskWorkunitId;
/**
* 任务ID
*/
......
......@@ -5,6 +5,7 @@ import com.ximai.common.annotation.Excel;
import com.ximai.common.core.domain.BaseEntity;
import com.ximai.mes.pro.domain.task.ProTaskWorkunit;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
......@@ -270,6 +271,13 @@ public class ProTaskVo extends BaseEntity {
*/
private Long idx;
@ApiModelProperty("标准工时")
private BigDecimal stdWorkingTime;
/**
* 工时单位
*/
private String stdWorkingTimeUom;
@TableField(exist = false)
private ProTaskWorkunit taskWorkunit;
......
......@@ -196,6 +196,7 @@ public interface ProTaskMapper extends BaseMapper<ProTask> {
List<ProTask> selectByTaskIds(@Param("taskIds")List<Long> taskIds);
List<ProTask> selectByTaskBatch(@Param("taskBatch")String taskBatch);
List<ProTask> selectByTaskWorkunitId(@Param("taskWorkunitId")Long taskWorkunitId);
void deleteByTaskBatch(@Param("taskBatch")String taskBatch);
......
......@@ -153,7 +153,7 @@ public interface ProTaskWorkunitMapper extends BaseMapper<ProTaskWorkunit> {
"\t, t.duration, ptw.schedule_end_date, t.color_code, t.request_date\n" +
"\t, t.attr1, t.attr2, t.attr3, t.attr4\n" +
"\t, t.create_time, t.update_by, t.update_time, ptw.STATUS, ptw.quantity_qualify, ptw.remark\n" +
"\t, ptw.quantity_unqualify, ptw.outsource_unit_price,ptw.outsourced, ptw.vendor_id,ptw.vendor_name, mw.workunit_id, mw.workunit_code, mw.workunit_name, wo.workorder_code\n" +
"\t,ptw.source_task_workunit_id, ptw.quantity_unqualify, ptw.outsource_unit_price,ptw.outsourced, ptw.vendor_id,ptw.vendor_name, mw.workunit_id, mw.workunit_code, mw.workunit_name, ptw.std_working_time,ptw.std_working_time_uom, wo.workorder_code\n" +
"\t, (case ptw.STATUS when 'BEGINNING' then 1 when 'PREPARE' then 2 when 'PAUSE' then 3 when 'ERROR_STOP' then 4 end) statusIndex\n" +
"from pro_task_workunit ptw\n" +
"\tleft join pro_task t on ptw.task_id = t.task_id\n" +
......
......@@ -11,6 +11,8 @@ import com.ximai.common.utils.data.DataUtil;
import com.ximai.common.utils.data.DateUtils;
import com.ximai.common.utils.data.ExceptionUtil;
import com.ximai.common.utils.data.StringUtils;
import com.ximai.mes.cal.domain.CalPlanWorkunit;
import com.ximai.mes.cal.service.ICalPlanWorkunitService;
import com.ximai.mes.constant.*;
import com.ximai.mes.md.domain.MdItem;
import com.ximai.mes.md.domain.MdWorkstation;
......@@ -162,6 +164,8 @@ public class ProTaskServiceImpl implements IProTaskService {
@Autowired
private IProMaterialRequestService proMaterialRequestService;
@Autowired
ICalPlanWorkunitService calPlanWorkunitService;
@Resource
private IMdWorkunitService iMdWorkunitService;
......@@ -1185,20 +1189,61 @@ public class ProTaskServiceImpl implements IProTaskService {
// 封装任务-工作单元
insertTaskWorkunit.setQuantity(splitQuantityConst);
insertTaskWorkunit.setSourceTaskWorkunitId(proTaskVo.getTaskWorkunitId());
insertTaskWorkunit.setQuantityProduced(BigDecimal.ZERO);
insertTaskWorkunit.setQuantityQualify(BigDecimal.ZERO);
insertTaskWorkunit.setQuantityUnqualify(BigDecimal.ZERO);
insertTaskWorkunit.setStatus(TaskStatusEnum.PREPARE.getStatus());
insertTaskWorkunit.setTaskType(type);
Date startTime = proTaskVo.getScheduleStartDate() == null ? new Date() : proTaskVo.getScheduleStartDate();
Date startTime = new Date();
insertTaskWorkunit.setScheduleStartDate(startTime);
insertTaskWorkunit.setScheduleEndDate(new Date(startTime.getTime() + proTaskVo.getDuration() * 1000 * 60 * 60));
QueryWrapper<CalPlanWorkunit> calPlanWorkunitQuery = new QueryWrapper<CalPlanWorkunit>();
calPlanWorkunitQuery.eq("rest_flag", 0);
calPlanWorkunitQuery.eq("workunit_id", insertTaskWorkunit.getWorkunitId());
calPlanWorkunitQuery.gt("start_date", startTime);
calPlanWorkunitQuery.orderByAsc("start_date");
//查询可用工作日历
List<CalPlanWorkunit> list = calPlanWorkunitService.selectListWithSchedule(calPlanWorkunitQuery);
if(insertTaskWorkunit.getStdWorkingTime() != null && insertTaskWorkunit.getStdWorkingTime().compareTo(BigDecimal.ZERO) > 0 && insertTaskWorkunit.getStdWorkingTimeUom() != null ){
Long endData = 0L;
if(insertTaskWorkunit.getStdWorkingTimeUom().equals("HOUR")){
endData = insertTaskWorkunit.getStdWorkingTime().multiply(new BigDecimal(1000 * 60 * 60)).multiply(splitQuantityConst).longValue();
}else if(insertTaskWorkunit.getStdWorkingTimeUom().equals("MIN")){
endData = insertTaskWorkunit.getStdWorkingTime().multiply(new BigDecimal(1000 * 60)).multiply(splitQuantityConst).longValue();
}else if(insertTaskWorkunit.getStdWorkingTimeUom().equals("SECOND")){
endData = insertTaskWorkunit.getStdWorkingTime().multiply(new BigDecimal(1000)).multiply(splitQuantityConst).longValue();
}
if(endData != 0){
if(list.size() > 0){
insertTaskWorkunit.setScheduleStartDate(list.get(0).getStartDate());
for (CalPlanWorkunit calPlanWorkunit : list){
if((calPlanWorkunit.getEndDate().getTime() - calPlanWorkunit.getStartDate().getTime()) > endData){
insertTaskWorkunit.setScheduleEndDate(new Date(calPlanWorkunit.getStartDate().getTime() + endData));
}else{
endData = endData - (calPlanWorkunit.getEndDate().getTime() - calPlanWorkunit.getStartDate().getTime());
}
}
if(endData > 0){
//不够用
insertTaskWorkunit.setScheduleEndDate(new Date(list.get(list.size() - 1).getEndDate().getTime() + endData));
}
}else{
insertTaskWorkunit.setScheduleEndDate(new Date(insertTaskWorkunit.getScheduleStartDate().getTime() + endData));
}
}else{
insertTaskWorkunit.setScheduleEndDate(insertTaskWorkunit.getScheduleStartDate());
}
}else{
insertTaskWorkunit.setScheduleEndDate(startTime);
}
insertTaskWorkunit.setDuration(insertTaskWorkunit.getScheduleEndDate().getTime() - insertTaskWorkunit.getScheduleStartDate().getTime());
if (Objects.equals(type, TaskConst.ASSIST_TASK)) {
insertTaskWorkunit.setApiFlag(true);
}
proTaskWorkunitService.insertProTaskWorkunit(insertTaskWorkunit);
return insertTaskWorkunit;
}
......
......@@ -637,4 +637,59 @@ public class ProTaskWorkunitServiceImpl implements IProTaskWorkunitService {
return null;
}
}
@Override
public Map<String, Object> printDataBySpil(Long taskWorkunitId) {
Map<String, Object> printData = new HashMap<>();
ArrayList valueList = new ArrayList();
printData.put("reportName","process.xml");
List<MdFactory> mdFactorys = mdFactoryMapper.selectLikeByName("上海希迈机电");
if(mdFactorys.size() > 0){
printData.put("reportName","process-cn.xml");
}
printData.put("valueList",valueList);
int i = 1;
SimpleDateFormat simpleDateFormat1 = new SimpleDateFormat("yyyy-MM-dd");
//for (String taskBatch : taskBatchs){
List<ProTask> taskBatchTasks = proTaskMapper.selectByTaskWorkunitId(taskWorkunitId);
String[] sp = taskBatchTasks.get(0).getTaskBatch().split("-");
if(taskBatchTasks.size() > 0){
List<TaskProPrintData> taskProPrintDatas = new ArrayList<>();
Map<String,Object> value = new HashMap<>();
valueList.add(value);
ProWorkorder proWorkorder = proWorkorderMapper.selectProWorkorderWorderCode(taskBatchTasks.get(0).getArrangeCode());
TaskProWorkorderPrintData taskProWorkorderPrintData = new TaskProWorkorderPrintData();
BeanUtil.copyProperties(proWorkorder,taskProWorkorderPrintData);
taskProWorkorderPrintData.setWorkorderType(dictDataService.getDictLabel("mes_workorder_type", taskProWorkorderPrintData.getWorkorderType()));
taskProWorkorderPrintData.setTaskBatch(sp[sp.length-1]);
value.put("header",taskProWorkorderPrintData);
value.put("detail",taskProPrintDatas);
Date over = null;
if(taskProWorkorderPrintData.getExpectStartDate() != null || taskProWorkorderPrintData.getRequestDate() != null){
for (ProTask proTask : taskBatchTasks){
TaskProPrintData taskProPrintData = new TaskProPrintData();
BeanUtil.copyProperties(proTask,taskProPrintData);
String begin = taskProWorkorderPrintData.getExpectStartDate() != null ? simpleDateFormat1.format(taskProWorkorderPrintData.getExpectStartDate()) : "空";
String end = taskProWorkorderPrintData.getRequestDate() != null ? simpleDateFormat1.format(taskProWorkorderPrintData.getRequestDate()) : "空";
taskProPrintData.setExpectStartDateString(begin);
taskProPrintData.setRequestDateString(end);
taskProPrintDatas.add(taskProPrintData);
if(proTask.getScheduleEndDate() != null){
if(over == null || over.getTime() < proTask.getScheduleEndDate().getTime()) {
over = proTask.getScheduleEndDate();
}
}
}
}
if(over != null){
taskProWorkorderPrintData.setRequestDate(over);
}
taskProWorkorderPrintData.setSize(i++);
taskProWorkorderPrintData.setDate(simpleDateFormat1.format(new Date()));
taskProWorkorderPrintData.setQuantity(taskBatchTasks.get(0).getQuantity());
//}
}
return printData;
}
}
......@@ -181,4 +181,6 @@ public interface IProTaskWorkunitService {
void outsourceConfirm(ProTaskWorkunit taskWorkunit);
Map<String, Object> printData(List<Long> taskIds);
Map<String, Object> printDataBySpil(Long taskWorkunitId);
}
......@@ -40,4 +40,11 @@ public class WorkOrderProgressRequest {
*/
@ApiModelProperty( "产品名称")
private String productName;
@ApiModelProperty( "工单状态")
private String workOrderStatus;
@ApiModelProperty( "产线")
private String lineName;
}
......@@ -267,12 +267,15 @@
pro_workorder pw
LEFT JOIN pro_feedback fe ON fe.workorder_id = pw.workorder_id
left join pro_task task on task.task_id = fe.task_id
left join md_item item on item.item_id = pw.product_id
<where>
<if test="workorderCode != null and workorderCode != ''">and pw.workorder_code = #{workorderCode}</if>
<if test="productId != null ">and pw.product_id = #{productId}</if>
<if test="productCode != null and productCode != ''">and pw.product_code = #{productCode}</if>
<if test="orderCode != null and orderCode !=''">and pw.order_code = #{orderCode}</if>
<if test="customerProjectNo != null and customerProjectNo !=''">and pw.customer_project_no = #{customerProjectNo}</if>
<if test="workOrderStatus != null and workOrderStatus !=''">and pw.status = #{workOrderStatus}</if>
<if test="lineName != null and lineName !=''">and item.line_name = #{lineName} </if>
</where>
GROUP BY
pw.workorder_id,
......
......@@ -345,6 +345,68 @@
</foreach>
</where>
</select>
<select id="selectByTaskWorkunitId" resultType="com.ximai.mes.pro.domain.task.ProTask">
SELECT ptw.task_workunit_id,
t.task_id,
t.task_code,
t.task_name,
t.workstation_id,
ws.workstation_code,
ws.workstation_name,
t.process_id,
t.arrange_code,
p.process_code,
p.process_name,
p.remark as processRemark,
t.item_id,
i.item_code,
i.item_name,
t.specification,
t.client_id,
t.client_code,
t.client_name,
t.client_nick,
t.start_time,
t.duration,
t.end_time,
t.color_code,
t.request_date,
t.remark,
t.attr1,
t.attr2,
t.attr3,
t.attr4,
t.create_by,
t.create_time,
t.update_by,
t.update_time,
t.idx,
t.task_batch,
ptw.task_workunit_id,
ptw.quantity,
ptw.quantity_produced,
ptw.quantity_changed,
ptw.quantity_qualify,
ptw.unit_of_measure,
ptw.STATUS,
mw.workunit_name workunit_name,
mw.workunit_id workunit_id,
mw.workunit_code workunit_code,
ptw.quantity_unqualify,
ptw.schedule_end_date,
ptw.schedule_start_date
FROM pro_task_workunit ptw
LEFT JOIN pro_task t ON t.task_id = ptw.task_id
LEFT JOIN pro_process p ON t.process_id = p.process_id
LEFT JOIN md_item i ON t.item_id = i.item_id
LEFT JOIN md_workunit mw ON ptw.workunit_id = mw.workunit_id
LEFT JOIN md_workstation ws ON t.workstation_id = ws.workstation_id
<where>
ptw.task_workunit_id = #{taskWorkunitId}
</where>
order by t.idx
</select>
<select id="selectByTaskBatch" resultType="com.ximai.mes.pro.domain.task.ProTask">
SELECT ptw.task_workunit_id,
t.task_id,
......@@ -405,6 +467,7 @@
</where>
order by t.idx
</select>
<select id="getProcessList"
resultType="com.ximai.mes.report.response.WorkOrderProgressProcessListResponse">
select * from pro_task where arrange_code = #{workorderCode} order by task_id
......
......@@ -128,6 +128,7 @@
<if test="stdWorkingTime != null">std_working_time,</if>
<if test="stdWorkingTimeUom != null">std_working_time_uom,</if>
<if test="unitPrice != null">unit_price,</if>
<if test="sourceTaskWorkunitId != null">source_task_workunit_id,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="taskId != null">#{taskId},</if>
......@@ -152,6 +153,7 @@
<if test="stdWorkingTime != null">#{stdWorkingTime},</if>
<if test="stdWorkingTimeUom != null">#{stdWorkingTimeUom},</if>
<if test="unitPrice != null">#{unitPrice},</if>
<if test="sourceTaskWorkunitId != null">#{sourceTaskWorkunitId},</if>
</trim>
</insert>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment