Merge remote-tracking branch 'origin/master'

master
mengjiao 6 months ago
commit d2962d71ed

@ -1,10 +1,12 @@
package com.op.mes.controller;
import java.io.IOException;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.*;
import javax.annotation.Resource;
@ -17,6 +19,7 @@ import com.op.common.core.domain.ExcelCol;
import com.op.common.core.domain.R;
import com.op.common.core.utils.DateUtils;
import com.op.common.core.utils.bean.BeanUtils;
import com.op.common.core.utils.poi.ExcelMapUtil;
import com.op.common.core.utils.uuid.IdUtils;
import com.op.common.datasource.creator.DynamicDatasourceCreator;
@ -52,6 +55,7 @@ import com.op.common.core.web.domain.AjaxResult;
import com.op.common.core.utils.poi.ExcelUtil;
import com.op.common.core.web.page.TableDataInfo;
import com.op.common.core.utils.poi.ExcelUtilDailyReport;
/**
* Controller
*
@ -651,6 +655,62 @@ public class MesReportWorkController extends BaseController {
Map resultMap = mesReportWorkService.getmonthProductionSut(mesMonthReportVo);
return success(resultMap);
}
/**
*
* @param response
* @param mesMonthReportVo
*/
@Log(title = "黑蚊香车间月度汇总表", businessType = BusinessType.EXPORT)
@PostMapping("/getmonthProductionSut/export")
public void export(HttpServletResponse response, MesMonthReportVo mesMonthReportVo) throws Exception {
SimpleDateFormat simpleDateFormat=new SimpleDateFormat("yyyy-MM-dd");
Date today = mesMonthReportVo.getMonthValue();
// 设置日历到本月1号
Calendar calendar = Calendar.getInstance();
calendar.setTime(today);
calendar.set(Calendar.DAY_OF_MONTH, 1);
String beginTime = simpleDateFormat.format(mesMonthReportVo.getMonthValue());
// 设置日历到下个月1号
calendar.add(Calendar.MONTH, 1);
String endTime = simpleDateFormat.format(calendar.getTime());
Map parammap =new HashMap();
parammap.put("beginTime",beginTime);
parammap.put("endTime",endTime);
mesMonthReportVo.setParams(parammap);
Map<String, List<?>> resultMap = mesReportWorkService.getmonthProductionSut(mesMonthReportVo);
List<String> dates = getDatesOfMonth(today);
for (String date : dates) {
System.out.println(date);
}
}
public static List<String> getDatesOfMonth(java.util.Date monthValue) {
// 将 java.util.Date 转换为 LocalDate
LocalDate localDate = monthValue.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
// 获取本月的第一天和最后一天
LocalDate firstDayOfMonth = localDate.withDayOfMonth(1);
LocalDate lastDayOfMonth = localDate.withDayOfMonth(localDate.lengthOfMonth());
// 创建一个列表来存储日期
List<String> dates = new ArrayList<>();
// 循环从本月1号到本月最后一天
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
LocalDate date = firstDayOfMonth;
while (!date.isAfter(lastDayOfMonth)) {
// 按照指定格式添加到列表中
dates.add(date.format(formatter));
date = date.plusDays(1);
}
return dates;
}
}

@ -65,48 +65,39 @@ public class MesUnitPriceReportController extends BaseController {
}
/**
*
*
*/
@RequiresPermissions("unitPriceReport:report:query")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") String id) {
MesUnitpriceReport mup=mesUnitpriceReportService.selectMesUnitpriceReportById(id);
MesUnitPrice mesUnitPrice=new MesUnitPrice();
mesUnitPrice.setProductCode(mup.getProductCode().substring(mup.getProductCode().length() - 11));
mesUnitPrice.setLineCode(mup.getLineCode());
List<MesUnitPrice> list = mesUnitPriceService.selectMesUnitPriceList(mesUnitPrice);
Map map=new HashMap();
map.put("MesUnitpriceReport",mup);
map.put("MesUnitPriceInfo",list);
return success(map);
return success(mesUnitpriceReportService.selectMesUnitpriceReportById(id));
}
/**
*
*
*/
@RequiresPermissions("unitPriceReport:report:add")
@Log(title = "计件工资统计", businessType = BusinessType.INSERT)
@Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody MesUnitpriceReport mesUnitpriceReport) {
return toAjax(mesUnitpriceReportService.insertMesUnitpriceReport(mesUnitpriceReport));
}
/**
*
*
*/
@RequiresPermissions("unitPriceReport:report:edit")
@Log(title = "计件工资统计", businessType = BusinessType.UPDATE)
@Log(title = "计件工资统计", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody MesUnitpriceReport mesUnitpriceReport) {
return toAjax(mesUnitpriceReportService.updateMesUnitpriceReport(mesUnitpriceReport));
}
/**
*
*
*/
@RequiresPermissions("unitPriceReport:report:remove")
@Log(title = "计件工资统计", businessType = BusinessType.DELETE)
@Log(title = "计件工资统计", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable String[] ids) {
return toAjax(mesUnitpriceReportService.deleteMesUnitpriceReportByIds(ids));

@ -4,7 +4,7 @@ import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.op.common.core.annotation.Excel;
import com.op.common.core.web.domain.BaseEntity;
import org.apache.poi.hpsf.Decimal;
import java.math.BigDecimal;
@ -26,7 +26,7 @@ public class MesUnitPrice extends BaseEntity {
*
*/
@Excel(name = "工厂")
private Integer factoryId;
private String factoryId;
/**
*
@ -102,11 +102,11 @@ public class MesUnitPrice extends BaseEntity {
return picId;
}
public void setFactoryId(Integer factoryId) {
public void setFactoryId(String factoryId) {
this.factoryId = factoryId;
}
public Integer getFactoryId() {
public String getFactoryId() {
return factoryId;
}

@ -1,11 +1,13 @@
package com.op.mes.domain;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.op.common.core.annotation.Excel;
import com.op.common.core.web.domain.BaseEntity;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Date;
/**
@ -25,14 +27,22 @@ public class MesUnitpriceReport extends BaseEntity {
/**
*
*/
@Excel(name = "工单编码")
@Excel(name = "工单")
private String workorderCode;
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "工单生产日期", width = 30, dateFormat = "yyyy-MM-dd", sort = 1)
private Date workOrderProductDate;
/**
* SAP
*/
@Excel(name = "SAP订单编码")
private String workorderCodeSap;
/**
*
*/
@ -44,45 +54,92 @@ public class MesUnitpriceReport extends BaseEntity {
@Excel(name = "产品名称")
private String productName;
// @Excel(name = "产线编码")
// private String sapCode;
@Excel(name = "产线编码")
private String lineCode;
@Excel(name = "SAP产线编码")
private String sapCode;
@Excel(name = "产线名称")
private String equipmentName;
/**
*
*/
@Excel(name = "工号")
private String userName;
/**
*
*/
@Excel(name = "操作者")
private String nickName;
@Excel(name = "岗位")
private String post;
/**
*
*/
@Excel(name = "子工序名称")
private String childprocessName;
/**
*
*/
@Excel(name = "当日工单报工总数")
private String orderQuantityP;
/**
*
*/
@Excel(name = "规格")
private String umrez;
/**
*
*/
@Excel(name = "全组数量")
private String orderQuantity;
@Excel(name = "工序单价")
private String attr1;
@Excel(name = "件数")
@Excel(name = "个人产量")
private String totalQuantity;
@Excel(name = " 薪酬(元)")
@Excel(name = " 计件薪酬(元)")
private BigDecimal result;
@Excel(name = "人数")
private String headCount;
// @Excel(name = "平均工资")
private String avgResult;
@Excel(name = "工时工资")
private String realWages;
/**
*
*/
// @Excel(name = "用户账号")
private String userName;
@Excel(name = "工时")
private String attr2;
@Excel(name = "扣款")
private BigDecimal kk;
@Excel(name = "保底")
private BigDecimal bd;
@Excel(name = "转岗")
private BigDecimal zg;
@Excel(name = "返工")
private BigDecimal fg;
@Excel(name = "试产")
private BigDecimal sc;
@Excel(name = "试机")
private BigDecimal sj;
@Excel(name = "特殊费用")
private BigDecimal tsfy;
@Excel(name = "夜班补贴")
private BigDecimal ybbt;
@Excel(name = "协产补贴")
private BigDecimal xcbt;
@Excel(name = "合计")
private BigDecimal hj;
// @Excel(name = "人数")
// private String headCount;
// @Excel(name = "平均工资")
// private String avgResult;
@Excel(name = "工时工资")
private String realWages;
/**
*
@ -96,45 +153,176 @@ public class MesUnitpriceReport extends BaseEntity {
*/
public BigDecimal getKk() {
return kk;
}
public void setKk(BigDecimal kk) {
this.kk = kk;
}
public BigDecimal getBd() {
return bd;
}
public void setBd(BigDecimal bd) {
this.bd = bd;
}
public BigDecimal getZg() {
return zg;
}
public void setZg(BigDecimal zg) {
this.zg = zg;
}
public BigDecimal getFg() {
return fg;
}
public void setFg(BigDecimal fg) {
this.fg = fg;
}
public BigDecimal getSc() {
return sc;
}
public void setSc(BigDecimal sc) {
this.sc = sc;
}
public BigDecimal getSj() {
return sj;
}
public void setSj(BigDecimal sj) {
this.sj = sj;
}
public BigDecimal getTsfy() {
return tsfy;
}
public void setTsfy(BigDecimal tsfy) {
this.tsfy = tsfy;
}
public BigDecimal getYbbt() {
return ybbt;
}
public void setYbbt(BigDecimal ybbt) {
this.ybbt = ybbt;
}
public BigDecimal getXcbt() {
return xcbt;
}
public void setXcbt(BigDecimal xcbt) {
this.xcbt = xcbt;
}
public BigDecimal getHj() {
return hj;
}
public void setHj(BigDecimal hj) {
this.hj = hj;
}
/**
* $column.columnComment
*/
// @Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
@Excel(name = "工时")
private String attr2;
public String getSapCode() {
return sapCode;
public Date getWorkOrderProductDate() {
return workOrderProductDate;
}
public void setSapCode(String sapCode) {
this.sapCode = sapCode;
public void setWorkOrderProductDate(Date workOrderProductDate) {
this.workOrderProductDate = workOrderProductDate;
}
public String getRealWages() {
return realWages;
public String getUmrez() {
return umrez;
}
public void setRealWages(String realWages) {
this.realWages = realWages;
public void setUmrez(String umrez) {
this.umrez = umrez;
}
public String getOrderQuantityP() {
return orderQuantityP;
}
public void setOrderQuantityP(String orderQuantityP) {
this.orderQuantityP = orderQuantityP;
}
public String getOrderQuantity() {
return orderQuantity;
}
public void setOrderQuantity(String orderQuantity) {
this.orderQuantity = orderQuantity;
}
public String getHeadCount() {
return headCount;
public String getPost() {
return post;
}
public void setHeadCount(String headCount) {
this.headCount = headCount;
public void setPost(String post) {
this.post = post;
}
public String getAvgResult() {
return avgResult;
// public String getSapCode() {
// return sapCode;
// }
//
// public void setSapCode(String sapCode) {
// this.sapCode = sapCode;
// }
public String getRealWages() {
if (realWages == null) {
return null;
}
try {
BigDecimal bd = new BigDecimal(realWages);
bd = bd.setScale(2, RoundingMode.HALF_UP); // 四舍五入保留两位小数
return bd.toString();
} catch (NumberFormatException e) {
return realWages; // 如果 realWages 不是一个有效的数字,直接返回原始值
}
}
public void setAvgResult(String avgResult) {
this.avgResult = avgResult;
public void setRealWages(String realWages) {
this.realWages = realWages;
}
// public String getHeadCount() {
// return headCount;
// }
//
// public void setHeadCount(String headCount) {
// this.headCount = headCount;
// }
//
// public String getAvgResult() {
// return avgResult;
// }
//
// public void setAvgResult(String avgResult) {
// this.avgResult = avgResult;
// }
public BigDecimal getResult() {
return result;

@ -1,15 +1,74 @@
package com.op.mes.domain.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.op.common.core.annotation.Excel;
import com.op.common.core.web.domain.BaseEntity;
import javax.xml.crypto.Data;
import java.lang.reflect.Field;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
public class MesMonthReportVo extends BaseEntity {
@JsonFormat(pattern = "yyyy-MM")
private Date monthValue;
@Excel(name = "产线")
private String equipment_name;
@Excel(name = "类别")
private String category;
@Excel(name = "当月汇总")
private String total_monthly_summary;
// 动态生成的日期字段
private List<String> dynamicDates;
// 生成当月1号到31号的日期列表格式为 yyyy-MM-dd
private List<String> generateDynamicDates() {
List<String> dates = new ArrayList<>();
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.DAY_OF_MONTH, 1);
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
int month = calendar.get(Calendar.MONTH);
while (calendar.get(Calendar.MONTH) == month) {
dates.add(dateFormat.format(calendar.getTime()));
calendar.add(Calendar.DAY_OF_MONTH, 1);
}
return dates;
}
public String getEquipment_name() {
return equipment_name;
}
public void setEquipment_name(String equipment_name) {
this.equipment_name = equipment_name;
}
public String getCategory() {
return category;
}
public void setCategory(String category) {
this.category = category;
}
public String getTotal_monthly_summary() {
return total_monthly_summary;
}
public void setTotal_monthly_summary(String total_monthly_summary) {
this.total_monthly_summary = total_monthly_summary;
}
public Date getMonthValue() {
return monthValue;
}

@ -12,8 +12,8 @@ import java.util.stream.Collectors;
import com.alibaba.csp.sentinel.util.StringUtil;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.alibaba.nacos.shaded.com.google.common.collect.Lists;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.google.common.collect.Lists;
import com.op.common.core.domain.R;
import com.op.common.core.utils.DateUtils;
import com.op.common.core.utils.ServletUtils;

@ -60,7 +60,6 @@ public class MesUnitPriceServiceImpl implements IMesUnitPriceService {
@Override
@DS("#header.poolName")
public List<MesUnitPrice> selectMesUnitPriceList(MesUnitPrice mesUnitPrice) {
mesUnitPrice.setCreateBy(SecurityUtils.getUsername());
return mesUnitPriceMapper.selectMesUnitPriceList(mesUnitPrice);
}
@ -144,7 +143,7 @@ public class MesUnitPriceServiceImpl implements IMesUnitPriceService {
}
} else {
failureNum++;
failureMsg.append("<br/>" + failureNum + "、产品 " + mesUnitPrice.getProductName() + " 已存在");
failureMsg.append("<br/>" + failureNum + "、产品 " + mesUnitPrice.getProductName() + "的工序"+mesUnitPrice.getChildprocessName()+" 已存在");
}
} catch (Exception e) {
failureNum++;

@ -8,6 +8,7 @@
<result property="id" column="id"/>
<result property="workorderCode" column="workorder_code"/>
<result property="workorderCodeSap" column="workorder_code_sap"/>
<result property="workOrderProductDate" column="work_order_product_date"/>
<result property="productName" column="product_name"/>
<result property="productCode" column="product_code"/>
<result property="lineCode" column="line_code"/>
@ -15,6 +16,7 @@
<result property="equipmentName" column="equipment_name"/>
<result property="userName" column="user_name"/>
<result property="nickName" column="nick_name"/>
<result property="post" column="post"/>
<result property="childprocessCode" column="childprocess_code"/>
<result property="childprocessName" column="childprocess_name"/>
<result property="totalQuantity" column="total_quantity"/>
@ -30,10 +32,23 @@
<result property="updateBy" column="update_by"/>
<result property="updateTime" column="update_time"/>
<result property="remark" column="remark"/>
<result property="umrez" column="umrez"/>
<result property="orderQuantityP" column="order_quantity_p"/>
<result property="orderQuantity" column="order_quantity"/>
<result property="kk" column="kk"/>
<result property="bd" column="bd"/>
<result property="zg" column="zg"/>
<result property="fg" column="fg"/>
<result property="sc" column="sc"/>
<result property="sj" column="sj"/>
<result property="tsfy" column="tsfy"/>
<result property="ybbt" column="ybbt"/>
<result property="xcbt" column="xcbt"/>
<result property="hj" column="hj"/>
</resultMap>
<sql id="selectMesUnitpriceReportVo">
select id, workorder_code, workorder_code_sap, product_name, product_code, user_name, nick_name, childprocess_code, childprocess_name, attr1, attr2, attr3, create_by, create_time, update_by, update_time, remark from mes_unitprice_report
select id, workorder_code, workorder_code_sap, product_name, product_code, user_name, nick_name, childprocess_code, childprocess_name, attr1, attr2, attr3,kk,bd,zg,fg,sc,sj,tsfy,ybbt,xcbt,create_by, create_time, update_by, update_time, remark from mes_unitprice_report
</sql>
<select id="selectMesUnitpriceReportList" parameterType="MesUnitpriceReport" resultMap="MesUnitpriceReportResult">
@ -41,27 +56,55 @@
mur.id,
mur.workorder_code,
mur.workorder_code_sap,
mur.work_order_product_date,
mur.product_code,
mur.product_name,
bp.umrez,
mrws.order_quantity as order_quantity_p,
mrw.order_quantity,
mur.line_code,
mur.attr2,
mur.remark,
be.sap_name as equipment_name,
be.sap_name AS equipment_name,
mur.user_name,
mur.nick_name,
mur.post,
mur.childprocess_code,
mup.childprocess_name,
mur.attr1 AS total_quantity,
CAST(mur.attr2 AS DECIMAL) * 16 AS real_wages,
mup.attr1,
mup.attr1*mur.attr1 AS result,
COUNT(*) OVER (PARTITION BY mur.workorder_code_sap, mur.childprocess_code) AS head_count,
mur.kk,
mur.bd,
mur.zg,
mur.fg,
mur.sc,
mur.sj,
mur.tsfy,
mur.ybbt,
mur.xcbt,
ROUND((COALESCE(mup.attr1, 0) * COALESCE(mur.attr1, 0)) - COALESCE(mur.kk, 0) + COALESCE(mur.bd, 0) +
COALESCE(mur.zg, 0) + COALESCE(mur.fg, 0) + COALESCE(mur.sc, 0) + COALESCE(mur.sj, 0) + COALESCE(mur.tsfy, 0) +
COALESCE(mur.ybbt, 0) + COALESCE(mur.xcbt, 0), 2) AS hj,
CASE
WHEN COALESCE(mur.attr2, 0) = 0 THEN 0
ELSE ROUND(
((COALESCE(mup.attr1, 0) * COALESCE(mur.attr1, 0)) - COALESCE(mur.kk, 0) + COALESCE(mur.bd, 0) +
COALESCE(mur.zg, 0) + COALESCE(mur.fg, 0) + COALESCE(mur.sc, 0) + COALESCE(mur.sj, 0) +
COALESCE(mur.tsfy, 0) + COALESCE(mur.ybbt, 0) + COALESCE(mur.xcbt, 0)) / COALESCE(mur.attr2, 1), 2)
END AS real_wages,
CAST (mup.attr1 AS DECIMAL(18, 6)) AS attr1,
ROUND(mup.attr1 * mur.attr1, 2) AS result,
mur.create_time
FROM
mes_unitprice_report mur
LEFT JOIN
mes_unit_price mup ON RIGHT(mur.product_code, 11) = mup.product_code AND mur.childprocess_code = mup.childprocess_code
LEFT JOIN base_equipment be ON be.sap_code=mur.line_code
LEFT JOIN ( SELECT parent_order, SUM ( quantity ) AS total_quantity FROM mes_report_work GROUP BY parent_order ) mrw ON mur.workorder_code = mrw.parent_order
LEFT JOIN mes_unit_price mup ON RIGHT ( mur.product_code, 11 ) = mup.product_code
AND mur.childprocess_code = mup.childprocess_code
LEFT JOIN base_equipment be ON be.sap_code= mur.line_code
LEFT JOIN ( SELECT parent_order, SUM ( quantity ) AS total_quantity,SUM(quantity_feedback) AS order_quantity FROM mes_report_work GROUP BY parent_order ) mrw ON mur.workorder_code = mrw.parent_order
LEFT JOIN ( SELECT workorder_code, SUM ( quantity ) AS total_quantity,SUM(quantity_feedback) AS order_quantity FROM mes_report_work GROUP BY workorder_code ) mrws ON mur.workorder_code = mrws.workorder_code
LEFT JOIN base_product bp ON bp.product_code=mur.product_code
LEFT JOIN pro_order_workorder pow ON pow.workorder_code=mur.workorder_code
<where>
<if test="workorderCode != null and workorderCode != ''">and workorder_code = #{workorderCode}</if>
<if test="workorderCodeSap != null and workorderCodeSap != ''">and mur.workorder_code_sap =
@ -91,26 +134,41 @@
<if test="attr2 != null and attr2 != ''">and attr2 = #{attr2}</if>
<if test="attr3 != null and attr3 != ''">and attr3 = #{attr3}</if>
<if test="params.beginTime != null and params.beginTime != '' and params.endTime != null and params.endTime != ''">
and mur.create_time between #{params.beginTime} and #{params.endTime}
and mur.work_order_product_date between #{params.beginTime} and #{params.endTime}
</if>
</where>
GROUP BY
mur.id,
mur.workorder_code,
mur.workorder_code_sap,
mur.work_order_product_date,
mur.product_code,
mur.product_name,
bp.umrez,
mur.attr1,
mur.attr2,
mur.line_code,
mur.remark,
be.sap_name,
mur.user_name,
mur.nick_name,
mur.post,
mur.childprocess_code,
mup.childprocess_name,
mrw.total_quantity,
mur.create_time,
mup.attr1;
mrw.order_quantity,
mrws.order_quantity,
mup.attr1,
mur.kk,
mur.bd,
mur.zg,
mur.fg,
mur.sc,
mur.sj,
mur.tsfy,
mur.ybbt,
mur.xcbt
</select>
@ -170,11 +228,23 @@
<!-- <if test="productCode != null">product_code = #{productCode},</if>-->
<!-- <if test="userName != null and userName != ''">user_name = #{userName},</if>-->
<!-- <if test="nickName != null and nickName != ''">nick_name = #{nickName},</if>-->
<if test="childprocessCode != null">childprocess_code = #{childprocessCode},</if>
<if test="childprocessName != null">childprocess_name = #{childprocessName},</if>
<!-- <if test="childprocessCode != null">childprocess_code = #{childprocessCode},</if>-->
<!-- <if test="childprocessName != null">childprocess_name = #{childprocessName},</if>-->
<if test="attr1 != null">attr1 = #{attr1},</if>
<if test="attr2 != null">attr2 = #{attr2},</if>
<if test="attr3 != null">attr3 = #{attr3},</if>
<if test="bd != null">bd = #{bd},</if>
<if test="kk != null">kk = #{kk},</if>
<if test="zg != null">zg = #{zg},</if>
<if test="fg != null">fg = #{fg},</if>
<if test="sc != null">sc = #{sc},</if>
<if test="sj != null">sj = #{sj},</if>
<if test="tsfy != null">tsfy = #{tsfy},</if>
<if test="ybbt != null">ybbt = #{ybbt},</if>
<if test="xcbt != null">xcbt = #{xcbt},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>

@ -113,7 +113,13 @@ public class OpenController extends BaseController {
return error("[factoryCode]不能为空");
}
//添加检测任务
return toAjax(openService.insertQcCheckTaskProduce(qcCheckTaskProduce));
int flag = openService.insertQcCheckTaskProduce(qcCheckTaskProduce);
if(flag != -100){
return toAjax(flag);
}else{
return AjaxResult.error("该工单批次上次首检尚未结束,不允许重复发起");
}
}
/**

@ -86,7 +86,7 @@ public interface OpenMapper {
String getSampNum(QcCheckTaskProduceDTO sampQua);
Date getLastTask(QcCheckTaskProduceDTO qcCheckTaskProduce);
String getLastTask(QcCheckTaskProduceDTO qcCheckTaskProduce);
List<SysNoticeGroup> getNoticesGroup(SysNoticeGroup noticeQo);

@ -391,11 +391,12 @@ public class OpenServiceImpl implements OpenService {
public int insertQcCheckTaskProduce(QcCheckTaskProduceDTO qcCheckTaskProduce) {
DynamicDataSourceContextHolder.push("ds_" + qcCheckTaskProduce.getFactoryCode());
logger.info("创建检验任务"+qcCheckTaskProduce.getCheckType()+":"+JSONObject.toJSONString(qcCheckTaskProduce));
// 1分钟不允许存在两条
Date lastData = openMapper.getLastTask(qcCheckTaskProduce);
if(this.oneMinHas(lastData)){
logger.info("【重复创建任务】orderNo:"+qcCheckTaskProduce.getOrderNo()+";"+"incomeBatchNo:"+qcCheckTaskProduce.getIncomeBatchNo());
return 0;
// 同一个工单同一个批次,上个检验没完成,下一个不允许执行
String lastStatus = openMapper.getLastTask(qcCheckTaskProduce);
if(StringUtils.isNotBlank(lastStatus) && !"2".equals(lastStatus)){
//logger.info("【重复创建任务】orderNo:"+qcCheckTaskProduce.getOrderNo()+";"+"incomeBatchNo:"+qcCheckTaskProduce.getIncomeBatchNo());
logger.info("【重复创建任务】"+JSONObject.toJSONString(qcCheckTaskProduce));
return -100;
}
qcCheckTaskProduce.setCreateTime(DateUtils.getNowDate());
@ -646,13 +647,20 @@ public class OpenServiceImpl implements OpenService {
}
public static void main(String args[]){
// 创建两个日期时间对象
LocalDateTime dateTime1 = LocalDateTime.of(2024, 4, 18, 9, 33); // 2023年1月1日 10:30
LocalDateTime dateTime2 = LocalDateTime.now(); // 2023年1月2日 11:45
// 计算分钟差
long minutesBetween = Duration.between(dateTime1, dateTime2).toMinutes();
if(minutesBetween<=1){
System.out.println("++++++++++++检验任务1分钟内生成过不再重复创建++++++++++++++");
// // 创建两个日期时间对象
// LocalDateTime dateTime1 = LocalDateTime.of(2024, 4, 18, 9, 33); // 2023年1月1日 10:30
// LocalDateTime dateTime2 = LocalDateTime.now(); // 2023年1月2日 11:45
// // 计算分钟差
// long minutesBetween = Duration.between(dateTime1, dateTime2).toMinutes();
// if(minutesBetween<=1){
// System.out.println("++++++++++++检验任务1分钟内生成过不再重复创建++++++++++++++");
// }
int f = -100;
if(f != -100){
System.out.println("-100");
}else{
System.out.println("0");
}
}

@ -207,8 +207,8 @@
where end_value>= #{quality} and #{quality}>=start_value and del_flag = '0'
and check_type = #{checkType}
</select>
<select id="getLastTask" resultType="java.util.Date">
select max(create_time) from qc_check_task
<select id="getLastTask" resultType="java.lang.String">
select check_status from qc_check_task
where check_type = #{checkType}
and order_no= #{orderNo}
and income_batch_no = #{incomeBatchNo}

@ -74,6 +74,7 @@ public class QcStaticTable extends BaseEntity {
private String workCenter;
private String recordId;
private String detailId;
private String checkNo;
@JsonFormat(pattern = "yyyy-MM-dd")
@ -108,6 +109,14 @@ public class QcStaticTable extends BaseEntity {
private BigDecimal upperDiff;
private BigDecimal downDiff;
public String getDetailId() {
return detailId;
}
public void setDetailId(String detailId) {
this.detailId = detailId;
}
public BigDecimal getUpperDiff() {
return upperDiff;
}

@ -79,4 +79,6 @@ public interface QcStaticTableMapper {
List<QcStaticTable> getProjectList(String checkType);
QcStaticTable getUpAndDown(QcStaticTable qcStaticTable);
@MapKey("detailId")
Map<String, QcStaticTable> defectMap(QcStaticTable qcStaticTable);
}

@ -177,15 +177,21 @@ public class QcStaticTableServiceImpl implements IQcStaticTableService {
}else if(qcStaticTable.getShiftId().equals("2")){
detailMap = qcStaticTableMapper.getProjectDetailNight(qcStaticTable);
}
Map<String, QcStaticTable> picsMap = qcStaticTableMapper.picsMap(qcStaticTable);
Map<String, QcStaticTable> defectMap = qcStaticTableMapper.defectMap(qcStaticTable);
if(defectMap.size()==0){
defectMap.put("0",null);
}
for (QcStaticTable project : projects) {
this.getDataFromMap(detailMap, project, picsMap);
this.getDataFromMap(detailMap, project, picsMap,defectMap);
}
return projects;
}
private void getDataFromMap(Map<String, QcStaticTable> detailMap, QcStaticTable project, Map<String, QcStaticTable> picsMap) {
private void getDataFromMap(Map<String, QcStaticTable> detailMap, QcStaticTable project, Map<String, QcStaticTable> picsMap,
Map<String, QcStaticTable> defectMap) {
String keystr = project.getProjectId() + "08";
QcStaticTable detail = detailMap.get(keystr);
if (detail != null) {
@ -194,6 +200,12 @@ public class QcStaticTableServiceImpl implements IQcStaticTableService {
} else if (detail != null && StringUtils.isNotBlank(detail.getStatus())) {
project.setColumn080090(detail.getStatus().equals("Y") ? "✓" : "✘");
}
QcStaticTable defect = defectMap.get(detail.getDetailId());
if(defect != null && StringUtils.isNotBlank(defect.getRemark())){
project.setColumn080090(project.getColumn080090()+" "+defect.getRemark());
}
QcStaticTable urlDTO = picsMap.get(detail.getRecordId());
if (urlDTO != null) {
project.setColumn080090(project.getColumn080090() + "," + urlDTO.getProjectId().replace("&amp;", "&"));//projectId存的照片路径
@ -210,6 +222,12 @@ public class QcStaticTableServiceImpl implements IQcStaticTableService {
} else if (detail != null && StringUtils.isNotBlank(detail.getStatus())) {
project.setColumn090100(detail.getStatus().equals("Y") ? "✓" : "✘");
}
QcStaticTable defect = defectMap.get(detail.getDetailId());
if(defect != null && StringUtils.isNotBlank(defect.getRemark())){
project.setColumn090100(project.getColumn090100()+" "+defect.getRemark());
}
QcStaticTable urlDTO = picsMap.get(detail.getRecordId());
if (urlDTO != null) {
project.setColumn090100(project.getColumn090100() + "," + urlDTO.getProjectId().replace("&amp;", "&"));//projectId存的照片路径
@ -226,6 +244,12 @@ public class QcStaticTableServiceImpl implements IQcStaticTableService {
} else if (detail != null && StringUtils.isNotBlank(detail.getStatus())) {
project.setColumn100110(detail.getStatus().equals("Y") ? "✓" : "✘");
}
QcStaticTable defect = defectMap.get(detail.getDetailId());
if(defect != null && StringUtils.isNotBlank(defect.getRemark())){
project.setColumn100110(project.getColumn100110()+" "+defect.getRemark());
}
QcStaticTable urlDTO = picsMap.get(detail.getRecordId());
if (urlDTO != null) {
project.setColumn100110(project.getColumn100110() + "," + urlDTO.getProjectId().replace("&amp;", "&"));//projectId存的照片路径
@ -242,6 +266,12 @@ public class QcStaticTableServiceImpl implements IQcStaticTableService {
} else if (detail != null && detail != null && StringUtils.isNotBlank(detail.getStatus())) {
project.setColumn110120(detail.getStatus().equals("Y") ? "✓" : "✘");
}
QcStaticTable defect = defectMap.get(detail.getDetailId());
if(defect != null && StringUtils.isNotBlank(defect.getRemark())){
project.setColumn110120(project.getColumn110120()+" "+defect.getRemark());
}
QcStaticTable urlDTO = picsMap.get(detail.getRecordId());
if (urlDTO != null) {
project.setColumn110120(project.getColumn110120() + "," + urlDTO.getProjectId().replace("&amp;", "&"));//projectId存的照片路径
@ -258,6 +288,12 @@ public class QcStaticTableServiceImpl implements IQcStaticTableService {
} else if (detail != null && StringUtils.isNotBlank(detail.getStatus())) {
project.setColumn123133(detail.getStatus().equals("Y") ? "✓" : "✘");
}
QcStaticTable defect = defectMap.get(detail.getDetailId());
if(defect != null && StringUtils.isNotBlank(defect.getRemark())){
project.setColumn123133(project.getColumn123133()+" "+defect.getRemark());
}
QcStaticTable urlDTO = picsMap.get(detail.getRecordId());
if (urlDTO != null) {
project.setColumn123133(project.getColumn123133() + "," + urlDTO.getProjectId().replace("&amp;", "&"));//projectId存的照片路径
@ -274,6 +310,12 @@ public class QcStaticTableServiceImpl implements IQcStaticTableService {
} else if (detail != null && StringUtils.isNotBlank(detail.getStatus())) {
project.setColumn133143(detail.getStatus().equals("Y") ? "✓" : "✘");
}
QcStaticTable defect = defectMap.get(detail.getDetailId());
if(defect != null && StringUtils.isNotBlank(defect.getRemark())){
project.setColumn133143(project.getColumn133143()+" "+defect.getRemark());
}
QcStaticTable urlDTO = picsMap.get(detail.getRecordId());
if (urlDTO != null) {
project.setColumn133143(project.getColumn133143() + "," + urlDTO.getProjectId().replace("&amp;", "&"));//projectId存的照片路径
@ -290,6 +332,12 @@ public class QcStaticTableServiceImpl implements IQcStaticTableService {
} else if (detail != null && StringUtils.isNotBlank(detail.getStatus())) {
project.setColumn143153(detail.getStatus().equals("Y") ? "✓" : "✘");
}
QcStaticTable defect = defectMap.get(detail.getDetailId());
if(defect != null && StringUtils.isNotBlank(defect.getRemark())){
project.setColumn143153(project.getColumn143153()+" "+defect.getRemark());
}
QcStaticTable urlDTO = picsMap.get(detail.getRecordId());
if (urlDTO != null) {
project.setColumn143153(project.getColumn143153() + "," + urlDTO.getProjectId().replace("&amp;", "&"));//projectId存的照片路径
@ -306,6 +354,12 @@ public class QcStaticTableServiceImpl implements IQcStaticTableService {
} else if (detail != null && StringUtils.isNotBlank(detail.getStatus())) {
project.setColumn153163(detail.getStatus().equals("Y") ? "✓" : "✘");
}
QcStaticTable defect = defectMap.get(detail.getDetailId());
if(defect != null && StringUtils.isNotBlank(defect.getRemark())){
project.setColumn153163(project.getColumn153163()+" "+defect.getRemark());
}
QcStaticTable urlDTO = picsMap.get(detail.getRecordId());
if (urlDTO != null) {
project.setColumn153163(project.getColumn153163() + "," + urlDTO.getProjectId().replace("&amp;", "&"));//projectId存的照片路径
@ -322,6 +376,12 @@ public class QcStaticTableServiceImpl implements IQcStaticTableService {
} else if (detail != null && StringUtils.isNotBlank(detail.getStatus())) {
project.setColumn163173(detail.getStatus().equals("Y") ? "✓" : "✘");
}
QcStaticTable defect = defectMap.get(detail.getDetailId());
if(defect != null && StringUtils.isNotBlank(defect.getRemark())){
project.setColumn163173(project.getColumn163173()+" "+defect.getRemark());
}
QcStaticTable urlDTO = picsMap.get(detail.getRecordId());
if (urlDTO != null) {
project.setColumn163173(project.getColumn163173() + "," + urlDTO.getProjectId().replace("&amp;", "&"));//projectId存的照片路径
@ -338,6 +398,12 @@ public class QcStaticTableServiceImpl implements IQcStaticTableService {
} else if (detail != null && StringUtils.isNotBlank(detail.getStatus())) {
project.setColumn180190(detail.getStatus().equals("Y") ? "✓" : "✘");
}
QcStaticTable defect = defectMap.get(detail.getDetailId());
if(defect != null && StringUtils.isNotBlank(defect.getRemark())){
project.setColumn180190(project.getColumn180190()+" "+defect.getRemark());
}
QcStaticTable urlDTO = picsMap.get(detail.getRecordId());
if (urlDTO != null) {
project.setColumn180190(project.getColumn180190() + "," + urlDTO.getProjectId().replace("&amp;", "&"));//projectId存的照片路径
@ -354,6 +420,12 @@ public class QcStaticTableServiceImpl implements IQcStaticTableService {
} else if (detail != null && StringUtils.isNotBlank(detail.getStatus())) {
project.setColumn190200(detail.getStatus().equals("Y") ? "✓" : "✘");
}
QcStaticTable defect = defectMap.get(detail.getDetailId());
if(defect != null && StringUtils.isNotBlank(defect.getRemark())){
project.setColumn190200(project.getColumn190200()+" "+defect.getRemark());
}
QcStaticTable urlDTO = picsMap.get(detail.getRecordId());
if (urlDTO != null) {
project.setColumn190200(project.getColumn190200() + "," + urlDTO.getProjectId().replace("&amp;", "&"));//projectId存的照片路径
@ -370,6 +442,12 @@ public class QcStaticTableServiceImpl implements IQcStaticTableService {
} else if (detail != null && StringUtils.isNotBlank(detail.getStatus())) {
project.setColumn200210(detail.getStatus().equals("Y") ? "✓" : "✘");
}
QcStaticTable defect = defectMap.get(detail.getDetailId());
if(defect != null && StringUtils.isNotBlank(defect.getRemark())){
project.setColumn200210(project.getColumn200210()+" "+defect.getRemark());
}
QcStaticTable urlDTO = picsMap.get(detail.getRecordId());
if (urlDTO != null) {
project.setColumn200210(project.getColumn200210() + "," + urlDTO.getProjectId().replace("&amp;", "&"));//projectId存的照片路径

@ -379,7 +379,7 @@
select
'','','',
qct.order_no, qct.material_code, qct.material_name, qct.quality, qct.unit,
qct.supplier_code, qct.supplier_name, qct.income_time,'','',
qct.supplier_code, qct.supplier_name,CONVERT(varchar(10), qct.income_time, 120) income_time,'','',
null,'', qct.check_type,'巡检检验' check_name,CONVERT(varchar(10),qct.create_time, 120) createTimeStr,
qct.confirm,qct.confirm_man_name
from qc_check_task qct
@ -409,7 +409,7 @@
and qct.check_type = 'checkTypeSCXJ'
</where>
GROUP BY qct.order_no, qct.material_code, qct.material_name, qct.quality, qct.unit,
qct.supplier_code, qct.supplier_name, qct.income_time, qct.check_type,CONVERT(varchar(10),qct.create_time, 120),
qct.supplier_code, qct.supplier_name,CONVERT(varchar(10), qct.income_time, 120), qct.check_type,CONVERT(varchar(10),qct.create_time, 120),
qct.confirm,qct.confirm_man_name
) t
left join pro_order_workorder pow on pow.workorder_code = t.order_no

@ -154,6 +154,7 @@
<select id="getProjectDetail" resultType="com.op.quality.domain.QcStaticTable">
select qctd.record_id recordId,
qctd.project_id projectId,
qctd.record_id detailId,
qctd.status,
qctd.remark,
CONVERT(VARCHAR(5),qctd.create_time, 108),
@ -176,12 +177,12 @@
left join qc_check_task_detail qctd on qct.record_id = qctd.belong_to
where qct.order_no = #{orderNo} and qct.check_type = 'checkTypeSCXJ' and qct.check_status = '2'
order by qctd.create_time
</select>
<select id="getProjectDetailNight" resultType="com.op.quality.domain.QcStaticTable">
select qctd.record_id recordId,
qctd.project_id projectId,
qctd.record_id detailId,
qctd.status,
qctd.remark,
CONVERT(VARCHAR(5),qctd.create_time, 108),
@ -400,4 +401,20 @@
from qc_check_type_project where project_id = #{projectNo}
and type_id = #{checkType}
</select>
<select id="defectMap" resultType="com.op.quality.domain.QcStaticTable">
SELECT
qctd.belong_to,
qctd.belong_to_detail detailId,
STUFF(
(SELECT ';' + defect_subclass+':'+ CONVERT(NVARCHAR(15), noOk_quality)
FROM qc_check_task_defect
WHERE belong_to = qctd.belong_to and belong_to_detail = qctd.belong_to_detail
FOR xml path('')
),1,1,''
) remark
FROM qc_check_task_defect qctd
left join qc_check_task qct on qctd.belong_to = qct.record_id
where qctd.del_flag = '0' and qct.order_no = #{orderNo}
GROUP by qctd.belong_to,qctd.belong_to_detail
</select>
</mapper>

Loading…
Cancel
Save