Merge remote-tracking branch 'origin/master'

master
杨万里 2 months ago
commit 2e8077d26f

@ -8,6 +8,8 @@ import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import java.util.Map;
/** auth YangWl
*
*/
@ -26,4 +28,7 @@ public interface RemoteEnergyService {
@PostMapping(value = "/record/dnbInstant/getNhEnergyDetail")
public R SyncNhEnergyDetail();
@PostMapping(value = "/record/dnbInstant/fixWwEnergyData",headers = {"poolName=ds_1000"})
public R syncFixWwEnergyData(@RequestBody Map<String ,String> map);
}

@ -20,7 +20,6 @@ import java.util.Map;
* @author OP
*/
@FeignClient(contextId = "remoteSapService", value = ServiceNameConstants.SAP_SERVICE, fallbackFactory = RemoteSapFallbackFactory.class)
public interface RemoteSapService {
@PostMapping("/sap/shopOrderSync")
public R<List<SapProOrder>> shopOrderSync(@RequestBody SapShopOrderQuery sapProOrder);
@ -157,8 +156,14 @@ public interface RemoteSapService {
public R handMadeInStorage(@RequestBody List<SapHandMadeInStorage> list);
@PostMapping("/sap/updateMaterialEntry")
R updateMaterialEntry(@RequestBody List<SapMaterialEntry> list, @RequestParam("optionType") String optionType // 关键指定value
);
R updateMaterialEntry(@RequestBody List<SapMaterialEntry> list, @RequestParam("optionType") String optionType);
/**
* 311
* **/
@PostMapping("/sap/sapTransferPosting")
R sapTransferPosting(@RequestBody List<Map<String,Object>> list);
}

@ -9,6 +9,8 @@ import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;
import java.util.Map;
@Component
public class RemoteEnergyFallbackFactory implements FallbackFactory<RemoteEnergyService> {
private static final Logger log = LoggerFactory.getLogger(RemoteEnergyFallbackFactory.class);
@ -36,6 +38,11 @@ public class RemoteEnergyFallbackFactory implements FallbackFactory<RemoteEnergy
public R SyncNhEnergyDetail() {
return R.fail("同步电表实时数据失败:" + throwable.getMessage());
}
@Override
public R syncFixWwEnergyData(Map<String ,String> map) {
return R.fail("修正威伟电表数据失败:" + throwable.getMessage());
}
};
}
}

@ -198,6 +198,16 @@ public class RemoteSapFallbackFactory implements FallbackFactory<RemoteSapServic
return R.fail("更新物料库位失败" + throwable.getMessage());
}
/**
* 311
*
* @param list
**/
@Override
public R sapTransferPosting(List<Map<String, Object>> list) {
return R.fail("311转储过账" + throwable.getMessage());
}
};
}
}

@ -200,6 +200,8 @@ public class BaseMonitorInfo extends BaseEntity {
private Boolean flag;
private String electricityMeterType;
public String getPhysicalCode() {
return physicalCode;
}
@ -481,6 +483,14 @@ public class BaseMonitorInfo extends BaseEntity {
this.connCode = connCode;
}
public String getElectricityMeterType() {
return electricityMeterType;
}
public void setElectricityMeterType(String electricityMeterType) {
this.electricityMeterType = electricityMeterType;
}
@Override
public String toString() {
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)

@ -16,6 +16,7 @@ import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;
/**
* Controller
@ -209,5 +210,28 @@ public class RecordDnbInstantController extends BaseController {
return AjaxResult.success();
}
/**
*
* **/
@PostMapping("/testGetNhEnergyDetail")
@ResponseBody
public void testGetNhEnergyDetail( HttpServletResponse response ,@RequestBody Map<String,String> params) {
List<RecordDnbInstant> list = recordDnbInstantService.testGetNhEnergyDetail(params);
ExcelUtil<RecordDnbInstant> util = new ExcelUtil<RecordDnbInstant>(RecordDnbInstant.class);
util.exportExcel(response, list, "导出");
}
/**
*
* **/
@PostMapping("/fixWwEnergyData")
@ResponseBody
public AjaxResult fixWwEnergyData(@RequestBody Map<String,String> params ) {
recordDnbInstantService.fixWwEnergyData(params);
return AjaxResult.success();
}
}

@ -32,7 +32,6 @@ public class RecordDnbInstant extends BaseEntity {
/**
*
*/
@Excel(name = "计量设备名称")
private String monitorName;
/**
@ -51,37 +50,31 @@ public class RecordDnbInstant extends BaseEntity {
/**
* A
*/
@Excel(name = "A项电压")
private BigDecimal vA;
/**
* B
*/
@Excel(name = "B项电压")
private BigDecimal vB;
/**
* C
*/
@Excel(name = "C项电压")
private BigDecimal vC;
/**
* A
*/
@Excel(name = "A项电流")
private BigDecimal iA;
/**
* B
*/
@Excel(name = "B项电流")
private BigDecimal iB;
/**
* C
*/
@Excel(name = "C项电流")
private BigDecimal iC;
/**
@ -92,7 +85,6 @@ public class RecordDnbInstant extends BaseEntity {
/**
*
*/
@Excel(name = "功率因数")
private BigDecimal glys;
/**
@ -104,25 +96,21 @@ public class RecordDnbInstant extends BaseEntity {
/**
*
*/
@Excel(name = "有功功率")
private BigDecimal activePower;
/**
*
*/
@Excel(name = "无功功率")
private BigDecimal reactivePower;
/**
*
*/
@Excel(name = "电耗量")
private BigDecimal consumption;
/**
*
*/
@Excel(name = "采集方式")
private Long collectType;
/**

@ -4,6 +4,7 @@ package com.op.energy.record.service;
import com.op.energy.record.domain.RecordDnbInstant;
import java.util.List;
import java.util.Map;
/**
* Service
@ -89,4 +90,8 @@ public interface IRecordDnbInstantService {
void getNhEnergyDetail();
void getNhEnergy();
List<RecordDnbInstant> testGetNhEnergyDetail(Map<String,String> params);
void fixWwEnergyData(Map<String,String> params);
}

@ -454,4 +454,46 @@ public class RecordDnbInstantServiceImpl implements IRecordDnbInstantService {
return defaultValue;
}
}
@Override
public List<RecordDnbInstant> testGetNhEnergyDetail(Map<String,String> params) {
List<RecordDnbInstant> list = new ArrayList<>();
/**
* /
* **/
AjaxResult electricQuantityRes= remoteOpenService.getElectricQuantity(params);
if(electricQuantityRes.isSuccess()){
JSONObject resData = JSONObject.parseObject(JSON.toJSONString(electricQuantityRes.get(AjaxResult.DATA_TAG)));
JSONArray array = JSONArray.parseArray(resData.get("Data").toString());
for (int i = 0; i < array.size(); i++) {
RecordDnbInstant instant = new RecordDnbInstant();
instant.setMonitorId(array.getJSONObject(i).getString("Address"));
instant.setZxyg(getSafeBigDecimal(array.getJSONObject(i), "ZYGDNSZ"));
instant.setCollectTime(DateUtils.dateTime("yyyy-MM-dd HH:mm", array.getJSONObject(i).getString("ReadingDate")));
list.add(instant);
}
}
return list;
}
@Override
@DS("#header.poolName")
public void fixWwEnergyData(Map<String,String> params) {
//获取威伟电表
BaseMonitorInfo query = new BaseMonitorInfo();
query.setElectricityMeterType("2");
List<BaseMonitorInfo> list = baseMonitorInfoMapper.selectBaseMonitorInfoList(query);
for (BaseMonitorInfo info : list) {
params.put("monitorId", info.getMonitorId());
reportPointDnbMapper.fixWwEnergyData(params);
}
}
}

@ -13,11 +13,13 @@ import com.op.energy.base.utils.ExportExcelUtil;
import com.op.energy.base.utils.SpringUtils;
import com.op.energy.report.domain.ExportReport;
import com.op.energy.report.domain.ReportOrderEnergyDTO;
import com.op.energy.report.domain.ReportPointDnb;
import com.op.energy.report.service.IDataAnalysisService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
@ -280,4 +282,24 @@ public class dataAnalysisController extends BaseController {
util.exportExcel(response, orderEnergyList, "单耗统计数据");
}
/**
*
* **/
@PostMapping("/energyTemplate")
public void energyTemplate(HttpServletResponse response) {
ExcelUtil<ReportPointDnb> util = new ExcelUtil<>(ReportPointDnb.class);
util.importTemplateExcel(response, "能耗补录-导入模板");
}
/**
*
* **/
@PostMapping("/energyImport")
public AjaxResult energyImport(MultipartFile file) throws Exception {
ExcelUtil<ReportPointDnb> util = new ExcelUtil<>(ReportPointDnb.class);
List<ReportPointDnb> list = util.importExcel(file.getInputStream());
return AjaxResult.success(dataAnalysisService.importReportPointDnb(list));
}
}

@ -56,7 +56,7 @@ public class ReportPointDnb extends BaseEntity {
/**
*
*/
@Excel(name = "计量设备位置")
@Excel(name = "计量设备位置", type = Excel.Type.EXPORT)
private String address;
/**
@ -68,7 +68,7 @@ public class ReportPointDnb extends BaseEntity {
/**
*
*/
@Excel(name = "价格")
@Excel(name = "价格", type = Excel.Type.EXPORT)
private BigDecimal price;
/**
@ -95,7 +95,7 @@ public class ReportPointDnb extends BaseEntity {
*
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "记录时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "记录时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss", type = Excel.Type.EXPORT)
private Date recordTime;
/**

@ -4,6 +4,7 @@ package com.op.energy.report.mapper;
import com.op.energy.report.domain.ReportOrderEnergyDTO;
import com.op.energy.report.domain.ReportPointDnb;
import com.op.energy.report.domain.ReportPointDnbDTO;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
@ -90,4 +91,10 @@ public interface ReportPointDnbMapper {
List<ReportPointDnb> selectPointDnbGroupList(ReportPointDnb pointDnb);
List<Map<String, String>> datePointDnbGroupList(ReportPointDnb lineDnb);
Integer fixWwEnergyData(@Param("params") Map<String,String> params);
int batchInsertReportPointDnb(@Param("list") List<ReportPointDnb> list);
}

@ -3,6 +3,7 @@ package com.op.energy.report.service;
import com.op.energy.base.domain.BaseLineLoss;
import com.op.energy.report.domain.ExportReport;
import com.op.energy.report.domain.ReportOrderEnergyDTO;
import com.op.energy.report.domain.ReportPointDnb;
import java.util.List;
import java.util.Map;
@ -108,4 +109,6 @@ public interface IDataAnalysisService {
List<ExportReport> classificationExportReport(Map paramMap);
public List<ReportOrderEnergyDTO> OrderEnergyList(ReportOrderEnergyDTO reportOrderEnergyDTO);
String importReportPointDnb(List<ReportPointDnb> list);
}

@ -22,6 +22,7 @@ import com.op.energy.report.domain.ReportPointWater;
import com.op.energy.report.mapper.ReportPointDnbMapper;
import com.op.energy.report.mapper.ReportPointWaterMapper;
import com.op.energy.report.service.IDataAnalysisService;
import org.apache.commons.collections4.ListUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -1047,4 +1048,15 @@ public class DataAnalysisServiceImpl implements IDataAnalysisService {
return reportOrderEnergyDTOList;
}
@Override
@DS("#header.poolName")
public String importReportPointDnb(List<ReportPointDnb> importList) {
if (importList.isEmpty()){
throw new RuntimeException("导入数据为空");
}
int successCount = reportPointDnbMapper.batchInsertReportPointDnb(importList);
return String.format("导入成功。上传数量:%d导入数量%d", importList.size(), successCount);
}
}

@ -81,6 +81,7 @@
<if test="roomCode != null ">and room_code = #{roomCode}</if>
<if test="addressCode != null ">and address_code = #{addressCode}</if>
<if test="connCode != null ">and conn_code = #{connCode}</if>
<if test="electricityMeterType != null ">and electricity_meter_type = #{electricityMeterType}</if>
</where>
</select>

@ -506,4 +506,67 @@
order by ert.pointTime asc
</select>
<select id="fixWwEnergyData" resultType="Integer" parameterType="java.util.Map" >
UPDATE a
SET expend = b.expend
FROM report_point_dnb a
INNER JOIN (
SELECT objId, expend
FROM (
SELECT
objId,
meter_value - ISNULL( LAG ( meter_value, 1 ) OVER ( PARTITION BY monitor_id ORDER BY record_time ), 0 ) AS expend,
ROW_NUMBER ( ) OVER ( ORDER BY record_time ) AS row_num
FROM report_point_dnb
WHERE DATEPART( MINUTE, record_time ) = 0
AND DATEPART( SECOND, record_time ) = 0
<if test="params.beginDate != null and params.beginDate != ''">
AND CONVERT ( VARCHAR, record_time, 23 ) >= #{params.beginDate}
AND CONVERT ( VARCHAR, record_time, 23 ) <![CDATA[ <= ]]> #{params.endDate}
</if>
<if test="params.beginDate == null || params.beginDate == ''">
AND CONVERT ( VARCHAR, record_time, 23 ) >= CONVERT(varchar, DATEADD(day, -2, GETDATE()), 23)
</if>
AND monitor_id = #{params.monitorId}
) n
WHERE row_num != 1
) b ON a.objid = b.objId
WHERE a.objid IN (
SELECT objId
FROM report_point_dnb
WHERE monitor_id = #{params.monitorId}
<if test="params.beginDate != null and params.beginDate != ''">
AND CONVERT ( VARCHAR, record_time, 23 ) >= #{params.beginDate}
AND CONVERT ( VARCHAR, record_time, 23 ) <![CDATA[ <= ]]> #{params.endDate}
</if>
<if test="params.beginDate == null || params.beginDate == ''">
AND CONVERT ( VARCHAR, record_time, 23 ) >= CONVERT(varchar, DATEADD(day, -2, GETDATE()), 23)
</if>
)
</select>
<insert id="batchInsertReportPointDnb" parameterType="java.util.List">
INSERT INTO report_point_dnb
(
monitor_id, monitor_name, begin_time, end_time,
record_time, expend, meter_value, collect_type
)
SELECT
t.monitorId, t.monitorName, t.beginTime, t.endTime,
t.recordTime, t.expend, t.meterValue, t.collectType
FROM (
<foreach collection="list" item="item" index="index" separator="UNION ALL">
SELECT
#{item.monitorId,jdbcType=VARCHAR} AS monitorId,
#{item.monitorName,jdbcType=VARCHAR} AS monitorName,
#{item.beginTime,jdbcType=TIMESTAMP} AS beginTime,
#{item.endTime,jdbcType=TIMESTAMP} AS endTime,
GETDATE() AS recordTime,
#{item.expend,jdbcType=DECIMAL} AS expend,
#{item.meterValue,jdbcType=DECIMAL} AS meterValue,
'1' AS collectType
</foreach>
) t
</insert>
</mapper>

@ -11,7 +11,9 @@ import org.springframework.stereotype.Component;
import com.op.common.core.utils.StringUtils;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
*
@ -291,5 +293,23 @@ public class RyTask {
logger.info("+++留样复检任务提醒++syncSendSampleCheckRemind+++++");
remoteQualityService.syncSendSampleCheckRemind();
}
/**********修正威伟电表数据(有参)*********/
public void syncFixWwEnergyData(String beginDate,String endDate){
logger.info("+++修正威伟电表数据(有参)++syncFixWwEnergyData+++++");
Map<String ,String> map = new HashMap<>();
map.put("beginDate",beginDate);
map.put("endDate",endDate);
remoteEnergyService.syncFixWwEnergyData(map);
}
/** 修正威伟电表数据(无参) **/
public void syncFixWwEnergyData(){
logger.info("+++修正威伟电表数据(无参)++syncFixWwEnergyData+++++");
Map<String ,String> map = new HashMap<>();
map.put("beginDate","");
map.put("endDate","");
remoteEnergyService.syncFixWwEnergyData(map);
}
}

@ -266,9 +266,9 @@ public class MesReportWorkConsumeServiceImpl implements IMesReportWorkConsumeSer
mesReportWorkMapper.updateAttr2AndRspos(params);
}
//attr2 0->1组件完成修改
// int f = mesReportWorkMapper.updateAttr2(workorder);
logger.info("组件修改完成:");
}
int f = mesReportWorkMapper.updateAttr2(workorder);
logger.info("组件修改完成:");
}
}

@ -313,4 +313,11 @@ public class OpenController extends BaseController {
}
/**
*
* **/
@GetMapping("/getClassInfoListByCheckType")
public AjaxResult getClassInfoListByCheckType(String checkType) {
return openService.getClassInfoListByCheckType(checkType);
}
}

@ -11,11 +11,13 @@ import com.op.system.api.domain.device.EquEquipmentDTO;
import com.op.system.api.domain.dto.WCSDTO;
import com.op.system.api.domain.mes.*;
import com.op.system.api.domain.quality.*;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
* rfidMapper
@ -109,6 +111,10 @@ public interface OpenMapper {
void updateEquipmentStatuss(EquEquipmentBo equEquipment);
EquEquipmentBo selectEquEquipmentByEquEquipmentCode(String equipmentCode);
@MapKey("id")
List<Map<String,Object>> getClassInfoListByCheckType(@Param(value = "checkType") String checkType);
//
// int updateEquBatchs(@Param("list") List<EquEquipmentDTO> updates);
//

@ -59,4 +59,6 @@ public interface OpenService {
AjaxResult getFrozenElectricity(NhQuery paramMap);
AjaxResult getAttRecord(HrQuery paramMap);
AjaxResult getClassInfoListByCheckType(String checkType);
}

@ -1059,4 +1059,24 @@ public class OpenServiceImpl implements OpenService {
public AjaxResult getAttRecord(HrQuery paramMap) {
return AjaxResult.success(hrApi.getAttRecord(paramMap));
}
@Override
public AjaxResult getClassInfoListByCheckType(String checkType) {
if (StringUtils.isBlank(checkType)){
return error("缺陷类型不能为空");
}
DynamicDataSourceContextHolder.push("ds_1000" );
try {
return success(openMapper.getClassInfoListByCheckType(checkType)) ;
}catch(Exception e){
logger.info(e.getMessage());
e.printStackTrace();
return error(e.getMessage());
}
finally {
DynamicDataSourceContextHolder.poll();
}
}
}

@ -626,4 +626,13 @@
and del_flag = '0'
</select>
<select id="getClassInfoListByCheckType" resultType="java.util.Map" parameterType="String">
select id,
class_name className
from qc_defect_type_class
where defect_code in(select defect_code from qc_defect_type where del_flag='0' and defect_type = #{checkType})
and del_flag = '0'
order by sort
</select>
</mapper>

@ -155,4 +155,15 @@ public class QcInterfaceController {
return qcInterfaceService.getLineQcData(qcInterface);
}
/**
*
*
* @param queryDate
* @return
*/
@GetMapping("/getBpMonthNoOk")
public Map<String, List<String>> getBpMonthNoOk(String queryDate) {
return qcInterfaceService.getBpMonthNoOk(queryDate);
}
}

@ -968,16 +968,16 @@ public class QcStaticTableController extends BaseController {
@Log(title = "白坯缺陷排列报表导出", businessType = BusinessType.EXPORT)
@PostMapping("/getMonthOfDataDefectExport")
public void getMonthOfDataDefectExport(HttpServletResponse response, QcStaticTable qcStaticTable) {
List<Map<String,String>> list = qcStaticTableService.getMonthOfDataDefect(qcStaticTable);
List<Map<String,String>> list = qcStaticTableService.getMonthOfDataDefectV2(qcStaticTable);
//表格结构数据
List<String> titils = qcStaticTableService.getDaysOfMonth(qcStaticTable);
ArrayList<ExcelCol> excelCols = new ArrayList<>();
excelCols.add(new ExcelCol("不良项目", "dataType", 30));
excelCols.add(new ExcelCol("不良项目", "defect", 30));
for(int m=0;m<titils.size();m++){
excelCols.add(new ExcelCol(titils.get(m), "monthNum"+m, 30));
excelCols.add(new ExcelCol(titils.get(m), titils.get(m), 30));
}
excelCols.add(new ExcelCol("累计", "rowSum", 30));
excelCols.add(new ExcelCol("累计", "count", 30));
String sheetName = "白坯缺陷排列报表";
SXSSFWorkbook workbook = null;
@ -1017,7 +1017,7 @@ public class QcStaticTableController extends BaseController {
@Log(title = "白坯不良项目报表导出", businessType = BusinessType.EXPORT)
@PostMapping("/getDefectItemDataExport")
public void getDefectItemDataExport(HttpServletResponse response, QcStaticTable qcStaticTable) {
List<Map<String,String>> list = qcStaticTableService.getDefectItemData(qcStaticTable);
List<Map<String,String>> list = qcStaticTableService.getDefectItemDataV2(qcStaticTable);
//表格结构数据
List<String> titils = qcStaticTableService.getDefectItemTitle(qcStaticTable);
@ -1060,10 +1060,11 @@ public class QcStaticTableController extends BaseController {
@Log(title = "白坯性能报表导出", businessType = BusinessType.EXPORT)
@PostMapping("/getDefectItemDataPCExport")
public void getDefectItemDataPCExport(HttpServletResponse response, QcStaticTable qcStaticTable) {
List<Map<String,String>> list = qcStaticTableService.getDefectItemDataPC(qcStaticTable);
List<Map<String,String>> list = qcStaticTableService.getDefectItemDataPCV2(qcStaticTable);
//表格结构数据
List<String> titils = qcStaticTableService.getDefectItemTitle(qcStaticTable);
titils.add("其他");
ArrayList<ExcelCol> excelCols = new ArrayList<>();
excelCols.add(new ExcelCol("项目", "dataType", 30));
for(int m=0;m<titils.size();m++){

@ -57,4 +57,7 @@ public interface QcInterfaceMapper {
List<QcInterface> getProduceNoOkList1(QcInterface qcInterface);
List<QcInterface> getCheckProjectsPie1(QcInterface qcInterface);
@MapKey("ymd")
Map<String, QcInterface> getBpMonthNoOk(String queryDate);
}

@ -39,4 +39,6 @@ public interface IQcInterfaceService {
QcLineChartDto getLineQcData(QcInterface qcInterface);
List<QcInterface> getCheckProjectsPieLL(QcInterface qcInterface);
Map<String, List<String>> getBpMonthNoOk(String queryDate);
}

@ -495,4 +495,33 @@ public class QcInterfaceServiceImpl implements IQcInterfaceService {
}
@Override
@DS("#header.poolName")
public Map<String, List<String>> getBpMonthNoOk(String queryDate) {
Map<String, List<String>> dtoMap = new HashMap<>();
String nowYMD = DateUtils.getDate();
String[] nowYMDs = nowYMD.split("-");
int nowMonth = Integer.parseInt(nowYMDs[1]);
List<String> monthNames = new ArrayList<>();
Map<String, QcInterface> noOkHzs = qcInterfaceMapper.getBpMonthNoOk(queryDate);
List<String> monthData = new ArrayList<>();
for (int mh = 1; mh <= nowMonth; mh++) {
String yyyymm = nowYMDs[0] + "-" + String.format("%02d", mh);
monthNames.add(yyyymm);
if (!CollectionUtils.isEmpty(noOkHzs)&&noOkHzs.get(yyyymm)!=null) {
monthData.add(noOkHzs.get(yyyymm).getNoOkQuality());
} else {
monthData.add("0");
}
}
dtoMap.put("month", monthNames);
dtoMap.put("monthData", monthData);
return dtoMap;
}
}

@ -1787,6 +1787,8 @@ public class QcStaticTableServiceImpl implements IQcStaticTableService {
if (StringUtils.isNotBlank(data.getAttr2())){
count = count + Integer.parseInt(data.getAttr2());
}
}else {
map.put(data.getAttr1(), "0");
}
}
map.put("count", Integer.toString(count));
@ -1800,7 +1802,7 @@ public class QcStaticTableServiceImpl implements IQcStaticTableService {
map2.put("defect","抽样数");
for (QcCheckTaskDefect data : list){
if ("合计".equals(data.getDefectSubclass())){
map1.put(data.getAttr1(),data.getAttr2());
map1.put(data.getAttr1(),StringUtils.isEmpty(data.getAttr2()) ? "0" : data.getAttr2());
map2.put(data.getAttr1(),data.getAttr3());
if (StringUtils.isNotBlank(data.getAttr2())){
count1 = count1 + Integer.parseInt(data.getAttr2());
@ -2081,6 +2083,7 @@ public class QcStaticTableServiceImpl implements IQcStaticTableService {
List<Map<String, String>> dtos = new ArrayList<>();
//获取不良种类
List<String> bpDefects = qcStaticTableMapper.getBpDefects(qcStaticTable);
bpDefects.add("其他");
List<QcCheckTaskDefect> monthList = qcStaticTableMapper.getBPDefectMothPCMapV2(qcStaticTable);
qcStaticTable.setYearMonth(null);
List<QcCheckTaskDefect> totalList = qcStaticTableMapper.getBPDefectMothPCMapV2(qcStaticTable);
@ -2099,21 +2102,16 @@ public class QcStaticTableServiceImpl implements IQcStaticTableService {
for (String defect : bpDefects) {
for (QcCheckTaskDefect item : list){
if (defect.equals(item.getDefectSubclass())){
if (StringUtils.isNotBlank(item.getAttr1())){
if ("rate".equals(type)){
result.put("item"+i, item.getAttr1());
}else {
if (StringUtils.isNotBlank(item.getAttr2())){
result.put("item"+i,new BigDecimal(item.getAttr1()).divide(new BigDecimal(item.getAttr2()),2,RoundingMode.HALF_UP).toString());
}else {
result.put("item"+i,"100");
}
}
if (StringUtils.isNotBlank(item.getAttr2()) && StringUtils.isNotBlank(item.getAttr3())){
BigDecimal itemNoOkRate = new BigDecimal(0);
itemNoOkRate = new BigDecimal(item.getAttr2()).divide(new BigDecimal(item.getAttr3()),4,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100));
result.put("item"+i,itemNoOkRate.toString());
}else {
result.put("item"+i,"0");
}
break;
}else {
result.put("item"+i,"0");
}
}
i++;
@ -2197,6 +2195,7 @@ public class QcStaticTableServiceImpl implements IQcStaticTableService {
//获取不良种类
List<String> bpDefects = qcStaticTableMapper.getBpDefects(qcStaticTable);
bpDefects.add("其他");
result.put("xData",bpDefects);
//当前查询月份的不良率
@ -2231,7 +2230,14 @@ public class QcStaticTableServiceImpl implements IQcStaticTableService {
boolean flag = true;
for (QcCheckTaskDefect item : monthList){
if (defect.equals(item.getDefectSubclass())){
yDataLeft.add(item.getAttr1());
if (StringUtils.isNotBlank(item.getAttr2()) && StringUtils.isNotBlank(item.getAttr3())){
//不良率
BigDecimal itemNoOkRate = new BigDecimal(0);
itemNoOkRate = new BigDecimal(item.getAttr2()).divide(new BigDecimal(item.getAttr3()),4,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100));
yDataLeft.add(itemNoOkRate.toString());
}else {
yDataLeft.add("0");
}
flag = false;
break;
}
@ -2251,7 +2257,14 @@ public class QcStaticTableServiceImpl implements IQcStaticTableService {
boolean flag = true;
for (QcCheckTaskDefect item : totalList){
if (defect.equals(item.getDefectSubclass())){
yDataRight.add(item.getAttr1());
if (StringUtils.isNotBlank(item.getAttr2()) && StringUtils.isNotBlank(item.getAttr3())){
//不良率
BigDecimal itemNoOkRate = new BigDecimal(0);
itemNoOkRate = new BigDecimal(item.getAttr2()).divide(new BigDecimal(item.getAttr3()),4,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100));
yDataRight.add(itemNoOkRate.toString());
}else {
yDataRight.add("0");
}
flag = false;
break;
}

@ -360,4 +360,20 @@
order by qctd.update_time desc
</select>
<select id="getBpMonthNoOk" parameterType="String" resultType="com.op.quality.domain.QcInterface" >
select
t.ymd,
sum(t.noOk_quality) noOkQuality
from(
select CONVERT(varchar(7),qct.income_time, 120) ymd,
qct.noOk_quality
from qc_check_task qct
where qct.order_type = 'bp'
and qct.del_flag='0'
and CONVERT(varchar(4),qct.income_time, 120) = CONVERT ( VARCHAR ( 4 ), GETDATE() , 120 )
) t
group by t.ymd
</select>
</mapper>

@ -1422,7 +1422,6 @@
LEFT JOIN qc_check_task_defect td ON qct.record_id = td.belong_to
LEFT JOIN qc_defect_type_class tc ON td.class_id = tc.id
WHERE qct.del_flag = '0'
AND tc.class_name IS NOT NULL
AND FORMAT ( qct.create_time, 'yyyy-MM' ) = #{yearMonth}
AND qct.order_type = 'bp'
GROUP BY tc.class_name, FORMAT ( qct.create_time, 'yyyy-MM-dd' )
@ -1436,7 +1435,6 @@
LEFT JOIN qc_check_task_defect td ON qct.record_id = td.belong_to
LEFT JOIN qc_defect_type_class tc ON td.class_id = tc.id
WHERE qct.del_flag = '0'
AND tc.class_name IS NOT NULL
AND FORMAT ( qct.create_time, 'yyyy-MM' ) = #{yearMonth}
AND qct.order_type = 'bp'
GROUP BY FORMAT ( qct.create_time, 'yyyy-MM-dd' )
@ -1452,7 +1450,6 @@
LEFT JOIN qc_check_task_defect td ON qct.record_id = td.belong_to
LEFT JOIN qc_defect_type_class tc ON td.class_id = tc.id
WHERE qct.del_flag = '0'
AND tc.class_name IS NOT NULL
AND qct.order_type = 'bp'
<if test="yearMonth !=null and yearMonth != ''">
AND FORMAT ( qct.create_time, 'yyyy-MM' ) = #{yearMonth}
@ -1468,15 +1465,14 @@
FROM
(
SELECT
tc.class_name defectSubclass,
SUM (CASE WHEN qct.check_status = 'N' THEN 1 ELSE 0 END) attr2,
ISNULL(tc.class_name,'其他') defectSubclass,
SUM (CASE WHEN qct.check_result = 'N' THEN 1 ELSE 0 END) attr2,
COUNT ( 0 ) attr3,
qct.income_batch_no
FROM qc_check_task qct
LEFT JOIN qc_check_task_defect td ON qct.record_id = td.belong_to
LEFT JOIN qc_defect_type_class tc ON td.class_id = tc.id
WHERE qct.del_flag = '0'
AND tc.class_name IS NOT NULL
AND qct.order_type = 'bp'
<if test="yearMonth !=null and yearMonth != ''">
AND FORMAT ( qct.create_time, 'yyyy-MM' ) = #{yearMonth}

@ -666,4 +666,13 @@ public class SapController extends BaseController {
public R updateMaterialEntry(@RequestBody List<SapMaterialEntry> list, @RequestParam("optionType") String optionType) {
return sapWmsService.updateMaterialEntry(list, optionType);
}
/**
* 311
* **/
@PostMapping("/sapTransferPosting")
@Log(title = "311转储过账", businessType = BusinessType.SAP)
public R sapTransferPosting(@RequestBody List<Map<String, Object>> list) {
return sapWmsService.sapTransferPosting(list);
}
}

@ -20,4 +20,6 @@ public interface SapWmsService {
R sapProductOutboundCostTW(List<Map<String, Object>> mapList);
R updateMaterialEntry(List<SapMaterialEntry> list, String optionType) ;
R sapTransferPosting(List<Map<String, Object>> list);
}

@ -375,4 +375,44 @@ public class SapWmsServicelmpl implements SapWmsService {
return R.fail(e.getMessage());
}
}
@Override
public R sapTransferPosting(List<Map<String, Object>> list) {
try {
if (list == null || list.isEmpty()) {
return R.fail();
}
JCoRepository repository = dest.getRepository();
JCoFunction func = repository.getFunction("ZMES_311_MB1B");
if (func == null) {
return R.fail("ZMES_311_MB1B函数不存在");
}
JCoTable item = func.getTableParameterList().getTable("L_ITEM");
log.info("311转储过账开始----------------------------------------");
for (Map<String,Object> map : list) {
item.appendRow();
item.setValue("PLANT", map.get("PLANT"));
item.setValue("LGORT", map.get("LGORT"));
item.setValue("MATNR", map.get("MATNR"));
item.setValue("QUANTITY", map.get("QUANTITY"));
item.setValue("MEINS", map.get("MEINS"));
item.setValue("MOVE_STLOC", map.get("MOVE_STLOC"));
}
func.execute(dest);
String msg = func.getExportParameterList().getString("L_MSG");
String code = func.getExportParameterList().getString("RETCODE");
String postCode = func.getExportParameterList().getString("MATERIALDOCUMENT");
if (!("0").equals(code)) {
return R.fail(msg);
} else {
Map<String,Object> map = new HashMap<>();
map.put("postCode", postCode);
return R.ok(map, msg);
}
}catch (Exception e){
return R.fail(e.getMessage());
}
}
}

@ -5,6 +5,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
import com.op.common.security.annotation.EnableCustomConfig;
import com.op.common.security.annotation.EnableRyFeignClients;
import com.op.common.swagger.annotation.EnableCustomSwagger2;
import org.springframework.cloud.openfeign.EnableFeignClients;
/**
*
@ -15,6 +16,7 @@ import com.op.common.swagger.annotation.EnableCustomSwagger2;
@EnableCustomSwagger2
@EnableRyFeignClients
@SpringBootApplication
@EnableFeignClients(basePackages = "com.op.system.api")
public class WmsApplication {
public static void main(String[] args) {
SpringApplication.run(WmsApplication.class, args);

@ -3,6 +3,7 @@ package com.op.wms.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.op.common.core.context.SecurityContextHolder;
import com.op.common.core.utils.uuid.IdUtils;
import com.op.wms.service.IOdsProcureOrderService;
import org.springframework.beans.factory.annotation.Autowired;
@ -210,4 +211,23 @@ public class OdsProcureOutOrderController extends BaseController {
odsProcureOrderService.batchSapTl(orderList);
return success();
}
/**
*
* **/
@PostMapping("/submitTransferPosting")
@Log(title = "电脑端提交转储过账")
public AjaxResult submitTransferPosting(@RequestBody List<OdsProcureOutOrder> orderList) {
return odsProcureOutOrderService.submitTransferPosting(orderList,SecurityContextHolder.getUserName());
}
/**
*
* **/
@PostMapping("/submitReversePosting")
@Log(title = "电脑端提交反冲过账")
public AjaxResult submitReversePosting(@RequestBody List<OdsProcureOutOrder> orderList) {
odsProcureOutOrderService.submitReversePosting(orderList,SecurityContextHolder.getUserName());
return success();
}
}

@ -0,0 +1,58 @@
package com.op.wms.controller;
import com.op.common.core.context.SecurityContextHolder;
import com.op.common.core.web.domain.AjaxResult;
import com.op.common.log.annotation.Log;
import com.op.wms.domain.OdsProcureOutOrder;
import com.op.wms.domain.query.BatchProductionMaterialQuery;
import com.op.wms.service.IWmsRawMaterialOutService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
*
*
* @author 019117
* @date
*/
@RestController
@RequestMapping("/rawMaterialOut")
@RequiredArgsConstructor
public class WmsRawMaterialOutController {
private final IWmsRawMaterialOutService wmsRawMaterialOutService;
/**
*
* **/
@GetMapping("/transferMaterialList")
public AjaxResult getTransferMaterialList(BatchProductionMaterialQuery query) {
List<OdsProcureOutOrder> list = wmsRawMaterialOutService.getTransferMaterialList(query);
return AjaxResult.success(list);
}
/**
*
* **/
@PostMapping("/submitTransferList")
@Log(title = "手机端提交转储数据")
public AjaxResult submitTransferMaterialList(@RequestBody OdsProcureOutOrder params) {
return wmsRawMaterialOutService.submitTransferMaterialList(params);
}
/**
*
* **/
@PostMapping("/submitReverseList")
@Log(title = "手机端提交反冲数据")
public AjaxResult submitReverseMaterialList(@RequestBody OdsProcureOutOrder params) {
return wmsRawMaterialOutService.submitReverseMaterialList(params);
}
}

@ -1022,4 +1022,22 @@ public class WmsToWCSmissionController {
return odsProcureOrderService.packingMaterialsInboundCompletedNew(wcsRequestParams);
}
/**
*
* **/
@GetMapping("/wmsStockAreaEntryList")
public AjaxResult getStockAreaEntryList(WmsStockAreaEntry params) {
List<WmsStockAreaEntry> list = odsProcureOrderService.getStockAreaEntryList(params);
return AjaxResult.success(list);
}
/**
*
* **/
@PostMapping("/submitMaterialEntry")
public AjaxResult submitMaterialEntry(@RequestBody List<WmsStockAreaEntry> list) {
odsProcureOrderService.submitMaterialEntry(list);
return AjaxResult.success();
}
}

@ -421,6 +421,11 @@ public class OdsProcureOutOrder extends BaseEntity {
* **/
private String sort;
/**
*
* **/
private String isPost = "0";
public String getWhCode() {
return whCode;
}
@ -741,6 +746,14 @@ public class OdsProcureOutOrder extends BaseEntity {
this.sort = sort;
}
public String getIsPost() {
return isPost;
}
public void setIsPost(String isPost) {
this.isPost = isPost;
}
@Override
public String toString() {
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)

@ -0,0 +1,72 @@
package com.op.wms.domain.query;
import lombok.Data;
import java.util.List;
/**
*
*
* @author 019117
* @date
*/
@Data
public class BatchProductionMaterialQuery {
/**
*
* **/
private String code;
/**
*
* **/
private String type;
/**
*
* **/
private String workOrderCode;
/**
*
* **/
private String factoryCode;
/**
*
* **/
private String operator;
/**
*
* **/
private String productDate;
/**
*
* **/
private String orderStatus;
/**
*
* **/
private String active;
/**
*
* **/
private String userDefined3;
/**
* -
* **/
private String userDefined6;
/**
*
* **/
private String userDefined10;
}

@ -0,0 +1,22 @@
package com.op.wms.mapper;
import com.op.wms.domain.query.BatchProductionMaterialQuery;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* remark
*
* @author 019117
* @date
*/
@Mapper
public interface MesPrepareMapper {
/**
*
* **/
List<String> selectMesPrepareList(BatchProductionMaterialQuery query);
}

@ -2,8 +2,9 @@ package com.op.wms.mapper;
import java.util.List;
import com.op.system.api.domain.sap.SapMaterialPosting;
import com.op.wms.domain.*;
import com.op.wms.domain.query.BatchProductionMaterialQuery;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
/**
@ -12,6 +13,7 @@ import org.apache.ibatis.annotations.Param;
* @author Open Platform
* @date 2023-07-06
*/
@Mapper
public interface OdsProcureOutOrderMapper {
/**
*
@ -188,4 +190,8 @@ public interface OdsProcureOutOrderMapper {
List<WmsStockAreaEntry> batchCheckDuplication(List<WmsStockAreaEntry> list );
void batchInsertMaterialEntry(List<WmsStockAreaEntry> list);
List<OdsProcureOutOrder> getBatchProductionMaterialList(BatchProductionMaterialQuery query);
void batchUpdateWmsOdsProcureOutOrder(@Param("orderList") List<OdsProcureOutOrder> orderList);
}

@ -3,7 +3,7 @@ package com.op.wms.mapper;
import com.op.wms.domain.ProOrderWorkorder;
import com.op.wms.domain.ProWetMaterialPlanDetail;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@ -15,6 +15,7 @@ import java.util.List;
* @date 2023-07-18
*/
@Mapper
public interface ProOrderWorkorderMapper {
List<ProOrderWorkorder> selectProOrderWorkorderList999(ProOrderWorkorder proOrderWorkorder);

@ -172,4 +172,8 @@ public interface IOdsProcureOrderService {
AjaxResult packingMaterialsInboundCompletedNew(WcsRequestParams wcsRequestParams);
AjaxResult packingMaterialsRequestOutboundNew(WcsOutBoundRequestParams wcsOutBoundRequestParams) throws Exception;
List<WmsStockAreaEntry> getStockAreaEntryList(WmsStockAreaEntry params);
void submitMaterialEntry(List<WmsStockAreaEntry> list);
}

@ -2,6 +2,7 @@ package com.op.wms.service;
import java.util.List;
import com.op.common.core.web.domain.AjaxResult;
import com.op.wms.domain.OdsProcureOutOrder;
/**
@ -90,4 +91,7 @@ public interface IOdsProcureOutOrderService {
List<OdsProcureOutOrder> selectOdsProcureOutOrderListZCTC(OdsProcureOutOrder odsProcureOutOrder);
public int removeReturn(List<String> iDs);
AjaxResult submitTransferPosting(List<OdsProcureOutOrder> list, String operator);
AjaxResult submitReversePosting( List<OdsProcureOutOrder> list, String operator);
}

@ -0,0 +1,23 @@
package com.op.wms.service;
import com.op.common.core.web.domain.AjaxResult;
import com.op.wms.domain.OdsProcureOutOrder;
import com.op.wms.domain.query.BatchProductionMaterialQuery;
import java.util.List;
/**
* remark
*
* @author 019117
* @date
*/
public interface IWmsRawMaterialOutService {
List<OdsProcureOutOrder> getTransferMaterialList(BatchProductionMaterialQuery query);
AjaxResult submitTransferMaterialList(OdsProcureOutOrder params);
AjaxResult submitReverseMaterialList(OdsProcureOutOrder params);
}

@ -29,6 +29,7 @@ import com.op.system.api.RemoteQualityService;
import com.op.system.api.RemoteSapService;
import com.op.system.api.domain.quality.QcCheckTaskIncomeDTO;
import com.op.system.api.domain.sap.SapBackflushMPQuery;
import com.op.system.api.domain.sap.SapMaterialEntry;
import com.op.system.api.domain.sap.SapMaterialPosting;
import com.op.system.api.domain.sap.SapPurchaseOrderQuery;
import com.op.wms.domain.wcs.WcsOutBoundRequestParams;
@ -41,6 +42,7 @@ import okhttp3.Response;
import java.io.IOException;
import java.util.stream.Collectors;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder;
@ -4145,4 +4147,45 @@ public class OdsProcureOrderServiceImpl implements IOdsProcureOrderService {
String result = HttpUtils.sendPostWechart(OutboundUrl,requestParam);
return AjaxResult.success(result);
}
@Override
@DS("#header.poolName")
public List<WmsStockAreaEntry> getStockAreaEntryList(WmsStockAreaEntry params) {
return odsProcureOutOrderMapper.getStockAreaEntryList(params);
}
@Override
@DS("#header.poolName")
public void submitMaterialEntry(List<WmsStockAreaEntry> list) {
List<SapMaterialEntry> sapList = new ArrayList<>();
List<WmsStockAreaEntry> duplicationList = odsProcureOutOrderMapper.batchCheckDuplication(list);
if (!duplicationList.isEmpty()){
List<String> materialCodeList = duplicationList.stream().map(WmsStockAreaEntry::getMaterialCode).collect(Collectors.toList());
throw new RuntimeException("物料:"+materialCodeList+"存在重复数据");
}
for (WmsStockAreaEntry item : list){
SapMaterialEntry entry = new SapMaterialEntry();
entry.setMaterialCode(item.getMaterialCode());
entry.setBatchCode(item.getBatchCode());
entry.setFactoryCode(item.getFactoryCode());
entry.setAreaCode(item.getAreaCode());
entry.setStatus(item.getStatus());
entry.setUserCode(item.getCreateBy());
sapList.add(entry);
}
//提交记录
odsProcureOutOrderMapper.batchInsertMaterialEntry(list);
//提交到sap
remoteSapService.updateMaterialEntry(sapList,"1");
}
}

@ -8,6 +8,7 @@ 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.uuid.IdUtils;
import com.op.common.core.web.domain.AjaxResult;
import com.op.common.security.utils.SecurityUtils;
import com.op.system.api.RemoteSapService;
import com.op.system.api.domain.sap.SapBackflushMPQuery;
@ -633,4 +634,98 @@ public class OdsProcureOutOrderServiceImpl implements IOdsProcureOutOrderService
}
@Override
@DS("#header.poolName")
public AjaxResult submitTransferPosting(List<OdsProcureOutOrder> orderList, String operator) {
List<Map<String,Object>> list = new ArrayList<>();
for(OdsProcureOutOrder order : orderList){
Map<String,Object> map = new HashMap<>();
map.put("PLANT", order.getSiteCode());
map.put("LGORT", "0001");
map.put("MATNR", order.getMaterialCode());
map.put("QUANTITY", order.getOutNumber());
map.put("MEINS", order.getUnit());
map.put("MOVE_STLOC", "0087");
list.add(map);
}
//过账
R result = remoteSapService.sapTransferPosting(list);
//过账后处理
return postHandle(result,orderList,operator);
}
@Override
@DS("#header.poolName")
public AjaxResult submitReversePosting(List<OdsProcureOutOrder> orderList, String operator) {
List<Map<String,Object>> list = new ArrayList<>();
for(OdsProcureOutOrder order : orderList){
Map<String,Object> map = new HashMap<>();
map.put("PLANT", order.getSiteCode());
map.put("LGORT", "0001");
map.put("MATNR", order.getMaterialCode());
map.put("QUANTITY", order.getOutNumber());
map.put("MEINS", order.getUnit());
map.put("MOVE_STLOC", "0013");
list.add(map);
}
//过账
R result = remoteSapService.sapTransferPosting(list);
//过账后处理
return postHandle(result,orderList,operator);
}
private AjaxResult postHandle( R result, List<OdsProcureOutOrder> orderList, String operator){
String msg = result.getMsg();
if (result.getCode() == 200) {
//过账成功
Map<String,Object> map = (Map<String,Object>) result.getData();
String postCode = (String) map.get("postCode");
updateOdsProcureOutOrderAndRawMissionOut(orderList, msg, postCode, operator, "2");
odsProcureOutOrderMapper.batchUpdateWmsOdsProcureOutOrder(orderList);
return AjaxResult.success(msg);
} else {
//过账失败
updateOdsProcureOutOrderAndRawMissionOut(orderList, msg, "", operator, "3");
odsProcureOutOrderMapper.batchUpdateWmsOdsProcureOutOrder(orderList);
return AjaxResult.error(msg);
}
}
//更新出库单及出库明细
private void updateOdsProcureOutOrderAndRawMissionOut(List<OdsProcureOutOrder> orderList,String msg, String postCode, String operator, String postingStatus) {
//遍历列表
for (OdsProcureOutOrder order : orderList) {
//更新更新出库数量以及出库状态
order.setOrderStatus("3");
order.setUserDefined9(postCode);
order.setUserDefined10(postingStatus);
order.setUserDefined11(msg);
order.setLastUpdateBy(operator);
order.setLastUpdateDate(new Date());
//新增出库明细
if ("2".equals(postingStatus)){
OdsProcureOutOrder missionOut = new OdsProcureOutOrder();
missionOut.setID(IdUtils.fastSimpleUUID());
missionOut.setProduceCode(order.getProduceCode());
missionOut.setMaterialCode(order.getMaterialCode());
missionOut.setMaterialDesc(order.getMaterialDesc());
missionOut.setUnit(order.getUnit());
missionOut.setPlanNumber(order.getOutNumber());
missionOut.setActive("1");
missionOut.setUserDefined3(order.getUserDefined3());
missionOut.setUserDefined4(order.getUserDefined4());
missionOut.setUserDefined5(postingStatus);
missionOut.setFactoryCode(order.getSiteCode());
missionOut.setCreateBy(operator);
missionOut.setCreateDate(new Date());
//出库记录
odsProcureOutOrderMapper.insertWmsRawMissionOut(missionOut);
}
}
}
}

@ -0,0 +1,235 @@
package com.op.wms.service.impl;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.op.common.core.domain.R;
import com.op.common.core.utils.uuid.IdUtils;
import com.op.common.core.web.domain.AjaxResult;
import com.op.system.api.RemoteSapService;
import com.op.system.api.domain.sap.SapBackflushMPQuery;
import com.op.wms.domain.OdsProcureOutOrder;
import com.op.wms.domain.query.BatchProductionMaterialQuery;
import com.op.wms.mapper.MesPrepareMapper;
import com.op.wms.mapper.OdsProcureOutOrderMapper;
import com.op.wms.service.IWmsRawMaterialOutService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.*;
/**
* remark
*
* @author 019117
* @date
*/
@Service
@RequiredArgsConstructor
public class WmsRawMaterialOutServiceImpl implements IWmsRawMaterialOutService {
private final OdsProcureOutOrderMapper odsProcureOutOrderMapper;
private final MesPrepareMapper mesPrepareMapper;
private final RemoteSapService remoteSapService;
@Override
@DS("#header.poolName")
public List<OdsProcureOutOrder> getTransferMaterialList(BatchProductionMaterialQuery query) {
//获取当前生产工单号
List<String> workOrderCodeList = mesPrepareMapper.selectMesPrepareList(query);
//查询包材出库单是否有数据(查询每张订单是否都有物料)
for (String code : workOrderCodeList) {
query.setUserDefined6(code);
List<OdsProcureOutOrder> list = odsProcureOutOrderMapper.getBatchProductionMaterialList(query);
if (list.isEmpty()){
//如果没有数据则从生产工单获取到生产物料
OdsProcureOutOrder order = new OdsProcureOutOrder();
order.setWorkorderCode(code);
List<OdsProcureOutOrder> orderList= odsProcureOutOrderMapper.selectMesPrepareDetailBC(order);
Integer orderItem = 0;
for (OdsProcureOutOrder order1: orderList) {
orderItem++;
OdsProcureOutOrder odsProcureOutOrder1 = new OdsProcureOutOrder();
odsProcureOutOrder1.setID(IdUtils.fastSimpleUUID());
odsProcureOutOrder1.setSiteCode(query.getFactoryCode());
odsProcureOutOrder1.setProduceCode(query.getCode());
odsProcureOutOrder1.setOutNumber(new BigDecimal("0"));
odsProcureOutOrder1.setMaterialCode(order1.getMaterialCode());
odsProcureOutOrder1.setMaterialDesc(order1.getMaterialDesc());
odsProcureOutOrder1.setPlanDate(new Date());
odsProcureOutOrder1.setUnit(order1.getUnit());
odsProcureOutOrder1.setActive("1");
odsProcureOutOrder1.setOrderStatus("1");
odsProcureOutOrder1.setPlanNumber(order1.getPlanNumber());
odsProcureOutOrder1.setUserDefined2(String.format("%05d", orderItem));
odsProcureOutOrder1.setUserDefined3("ZC");
odsProcureOutOrder1.setUserDefined4(query.getCode());
odsProcureOutOrder1.setUserDefined10("1");
odsProcureOutOrder1.setUserDefined5(order1.getNeedDate());
odsProcureOutOrder1.setUserDefined6(code);
odsProcureOutOrder1.setCreateBy(query.getOperator());
odsProcureOutOrder1.setCreateDate(new Date());
//写入包材出库单
odsProcureOutOrderMapper.insertWmsOdsProcureOutOrder(odsProcureOutOrder1);
}
}
}
//重新查询(相同物料需要合并计算)
query.setUserDefined6(null);
return odsProcureOutOrderMapper.getBatchProductionMaterialList(query);
}
@Override
@DS("#header.poolName")
public AjaxResult submitTransferMaterialList(OdsProcureOutOrder params) {
//更新出库单及新增出库明细
updateOdsProcureOutOrder(params);
//获取已完成,但没有过账的转储物料
BatchProductionMaterialQuery query = new BatchProductionMaterialQuery();
query.setUserDefined3("ZC");
query.setOrderStatus("3");
query.setActive("1");
query.setUserDefined10("1");
List<OdsProcureOutOrder> orderList = odsProcureOutOrderMapper.getBatchProductionMaterialList(query);
if (orderList.isEmpty()){
return AjaxResult.success();
}
List<Map<String,Object>> list = new ArrayList<>();
for(OdsProcureOutOrder order : orderList){
Map<String,Object> map = new HashMap<>();
map.put("PLANT", params.getFactoryCode());
map.put("LGORT", "0001");
map.put("MATNR", order.getMaterialCode());
map.put("QUANTITY", order.getOutNumber());
map.put("MEINS", order.getUnit());
map.put("MOVE_STLOC", "0087");
list.add(map);
}
//过账
R result = remoteSapService.sapTransferPosting(list);
return postHandle(result,orderList);
}
@Override
@DS("#header.poolName")
public AjaxResult submitReverseMaterialList(OdsProcureOutOrder params) {
//更新出库单及新增出库明细
updateOdsProcureOutOrder(params);
//获取已完成,但没有过账的反冲物料
BatchProductionMaterialQuery query = new BatchProductionMaterialQuery();
query.setUserDefined3("X");
query.setOrderStatus("3");
query.setActive("1");
query.setUserDefined10("1");
List<OdsProcureOutOrder> orderList = odsProcureOutOrderMapper.getBatchProductionMaterialList(query);
if (orderList.isEmpty()){
return AjaxResult.success();
}
List<Map<String,Object>> list = new ArrayList<>();
for(OdsProcureOutOrder order : orderList){
Map<String,Object> map = new HashMap<>();
map.put("PLANT", params.getFactoryCode());
map.put("LGORT", "0001");
map.put("MATNR", order.getMaterialCode());
map.put("QUANTITY", order.getOutNumber());
map.put("MEINS", order.getUnit());
map.put("MOVE_STLOC", "0013");
list.add(map);
}
R result = remoteSapService.sapTransferPosting(list);
return postHandle(result,orderList);
}
//更新出库单及出库明细
private void updateOdsProcureOutOrder(OdsProcureOutOrder params) {
List<OdsProcureOutOrder> orderList = params.getOrderList();
//遍历列表
for (OdsProcureOutOrder order : orderList) {
//计划数量
BigDecimal planQty = order.getPlanNumber();
//已出数量
BigDecimal outQty = order.getOutNumber();
//当前需出库数量
BigDecimal currentQty = order.getQty();
//应出数量 = 已出+需出
BigDecimal totalQty = BigDecimal.ZERO;
if (currentQty == null) {
totalQty = outQty;
}else {
totalQty = outQty.add(currentQty);
}
//已出+需出=计划数量,则满足出库状态
if (totalQty.compareTo(planQty) >= 0) {
order.setOrderStatus("3");
}else {
order.setOrderStatus("2");
}
if ("1".equals(order.getIsPost())){
order.setOrderStatus("3");
}
if ("3".equals(order.getOrderStatus())) {
//应出数量为0返回错误
if (totalQty.compareTo(BigDecimal.ZERO) == 0) {
throw new RuntimeException("物料编码:"+ order.getMaterialCode() + "出库数量为0无法过账");
}
}
//更新已出数量
order.setOutNumber(totalQty);
order.setLastUpdateBy(params.getCreateBy());
order.setLastUpdateDate(new Date());
//更新出库单
odsProcureOutOrderMapper.updateWmsOdsProcureOutOrder(order);
//新增出库明细
order.setID(IdUtils.fastSimpleUUID());
order.setActive("1");
order.setCreateBy(params.getCreateBy());
order.setCreateDate(new Date());
order.setUserDefined1(null);
order.setUserDefined2(null);
odsProcureOutOrderMapper.insertWmsRawMissionOut(order);
}
}
//过账信息处理
private AjaxResult postHandle(R result, List<OdsProcureOutOrder> list) {
int code = result.getCode();
OdsProcureOutOrder order = new OdsProcureOutOrder();
String msg = result.getMsg();
order.setUserDefined11(msg);
if (code == 200) {
//过账成功
Map<String,Object> map = (Map<String,Object>) result.getData();
String userDefined9 = (String) map.get("postCode");
order.setUserDefined9(userDefined9);
//成功
order.setUserDefined10("2");
odsProcureOutOrderMapper.updateWMSOdsProcureOutOrderByids(order, list);
return AjaxResult.success(msg);
} else {
order.setUserDefined9("");
//失败
order.setUserDefined10("3");
odsProcureOutOrderMapper.updateWMSOdsProcureOutOrderByids(order, list);
return AjaxResult.error(msg);
}
}
}

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.op.wms.mapper.MesPrepareMapper">
<select id="selectMesPrepareList" parameterType="com.op.wms.domain.query.BatchProductionMaterialQuery" resultType="String">
select ow.workorder_code workorderCode
from mes_prepare ms
left join pro_order_workorder ow on ms.workorder_code = ow.workorder_code
<where>
ow.del_flag = '0' and ow.parent_order = '0' and ms.del_flag = '0'
<if test="productDate != null "> and ow.product_date = #{productDate}</if>
</where>
</select>
</mapper>

@ -2203,4 +2203,118 @@
)
</foreach>
</insert>
<select id="getBatchProductionMaterialList" parameterType="com.op.wms.domain.query.BatchProductionMaterialQuery" resultType="com.op.wms.domain.OdsProcureOutOrder">
SELECT
ID,
Produce_Code produceCode,
Material_Code materialCode,
Material_Desc materialDesc,
Site_code siteCode,
Site_code factoryCode,
Plan_Number planNumber,
COALESCE ( Out_Number, 0 ) AS outNumber,
unit,
Order_Status orderStatus,
User_Defined1 userDefined1,
User_Defined2 userDefined2,
User_Defined3 userDefined3,
User_Defined4 userDefined4,
User_Defined6 userDefined6,
User_Defined7 userDefined7,
User_Defined8 userDefined8,
User_Defined9 userDefined9,
User_Defined10 userDefined10
FROM wms_ods_procure_out_order
<where>
<if test="code != null and code != ''"> and User_Defined4 = #{code} </if>
<if test="orderStatus != null and orderStatus != ''"> and Order_Status = #{orderStatus} </if>
<if test="active != null and active != ''"> and Active = #{active} </if>
<if test="userDefined3 != null and userDefined3 != ''"> and User_Defined3 = #{userDefined3} </if>
<if test="userDefined6 != null and userDefined6 != ''"> and User_Defined6 = #{userDefined6} </if>
<if test="userDefined10 != null and userDefined10 != ''"> and User_Defined10 = #{userDefined10} </if>
</where>
ORDER BY userDefined10, userDefined6, userDefined2
</select>
<update id="batchUpdateWmsOdsProcureOutOrder" parameterType="com.op.wms.domain.OdsProcureOutOrder">
<foreach collection="orderList" item="item" separator=";" open="" close="">
UPDATE wms_ods_procure_out_order
SET
order_status = #{item.orderStatus},
Out_Number = #{item.outNumber},
user_defined9 = #{item.userDefined9},
user_defined10 = #{item.userDefined10},
user_defined11 = #{item.userDefined11},
last_update_by = #{item.lastUpdateBy},
last_update_date = #{item.lastUpdateDate}
WHERE
id = #{item.ID}
</foreach>
</update>
<select id="getStockAreaEntryList" resultType="com.op.wms.domain.WmsStockAreaEntry" parameterType="com.op.wms.domain.WmsStockAreaEntry">
SELECT
CONVERT(VARCHAR, pow.product_date, 23) productionDate,
SUBSTRING(pow.workorder_code_sap, 4, 10) workOrderCode,
SUBSTRING(pow.product_code, 8,11) materialCode,
pow.product_name materialName,
CASE
WHEN LEN(powb.batch_code) = 24 THEN SUBSTRING(powb.batch_code, 13, 10)
WHEN LEN(powb.batch_code) <![CDATA[ < ]]> 24 THEN powb.batch_code
WHEN LEN(powb.batch_code) > 24 THEN CONVERT(VARCHAR(8), pow.create_time, 112)
ELSE ''
END batchCode
FROM pro_order_workorder pow
LEFT JOIN pro_order_workorder_batch powb ON pow.workorder_id = powb.workorder_id
WHERE powb.del_flag = '0' AND pow.product_code like '00000001%' and pow.parent_order = '0'
<if test="beginDate != null ">and CONVERT(varchar(10),pow.product_date, 120) >= '${beginDate}'</if>
<if test="endDate != null ">and '${endDate}' >= CONVERT(varchar(10),pow.product_date, 120)</if>
<if test="workOrderCode != null and workOrderCode != ''">and pow.workorder_code like concat('%', #{workOrderCode}, '%')</if>
<if test="status != null and status != ''">and pow.status = #{status}</if>
<if test="materialCode != null and materialCode != ''">and pow.product_code like concat('%', #{materialCode},'%')</if>
ORDER BY pow.workorder_code_sap, powb.batch_code
</select>
<select id="batchCheckDuplication" resultType="com.op.wms.domain.WmsStockAreaEntry" parameterType="list">
SELECT material_code materialCode, batch_code batchCode, factory_code factoryCode, area_code areaCode
FROM wms_material_entry
WHERE CONCAT(material_code, batch_code, factory_code, area_code) IN
<foreach collection="list" item="item" open="(" separator="," close=")">
CONCAT(#{item.materialCode}, #{item.batchCode}, #{item.factoryCode}, #{item.areaCode})
</foreach>
</select>
<insert id="batchInsertMaterialEntry" parameterType="list">
INSERT INTO wms_material_entry (
work_order_code,
material_code,
batch_code,
factory_code,
location,
area_code,
status,
create_time,
create_by
)
VALUES
<foreach collection="list" item="item" separator=",">
(
#{item.workOrderCode},
#{item.materialCode},
#{item.batchCode},
#{item.factoryCode},
#{item.location},
#{item.areaCode},
#{item.status},
GETDATE(),
#{item.createBy}
)
</foreach>
</insert>
</mapper>

@ -28,6 +28,14 @@
<artifactId>op-modules</artifactId>
<packaging>pom</packaging>
<dependencies>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
<description>
op-modules业务模块
</description>

Loading…
Cancel
Save