2024-07-04 设备模块-备品备件出入库

master
A0010407 9 months ago
parent a79aa07f32
commit b13b68d10a

@ -15,8 +15,8 @@ import org.springframework.web.bind.annotation.RestController;
import com.op.common.log.annotation.Log;
import com.op.common.log.enums.BusinessType;
import com.op.common.security.annotation.RequiresPermissions;
import com.op.device.domain.SparePartsInStorage;
import com.op.device.service.ISparePartsInOutStorageService;
import com.op.device.domain.EquSparepartsInOut;
import com.op.device.service.IEquSparepartsInOutService;
import com.op.common.core.web.controller.BaseController;
import com.op.common.core.web.domain.AjaxResult;
import com.op.common.core.utils.poi.ExcelUtil;
@ -30,18 +30,18 @@ import com.op.common.core.web.page.TableDataInfo;
*/
@RestController
@RequestMapping("/sparepartsInOutStorage")
public class SparePartsInOutStorageController extends BaseController {
public class EquSparepartsInOutController extends BaseController {
@Autowired
private ISparePartsInOutStorageService sparePartsInOutStorageService;
private IEquSparepartsInOutService equSparepartsInOutService;
/**
*
*/
@RequiresPermissions("device:sparepartsInOutStorage:list")
@GetMapping("/list")
public TableDataInfo list(SparePartsInStorage sparePartsInStorage) {
public TableDataInfo list(EquSparepartsInOut equSparepartsInOut) {
startPage();
List<SparePartsInStorage> list = sparePartsInOutStorageService.selectSparePartsInStorageList(sparePartsInStorage);
List<EquSparepartsInOut> list = equSparepartsInOutService.selectEquSparepartsInOutList(equSparepartsInOut);
return getDataTable(list);
}
@ -51,9 +51,9 @@ public class SparePartsInOutStorageController extends BaseController {
@RequiresPermissions("device:sparepartsInOutStorage:export")
@Log(title = "备品备件出入库", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, SparePartsInStorage sparePartsInStorage) {
List<SparePartsInStorage> list = sparePartsInOutStorageService.selectSparePartsInStorageList(sparePartsInStorage);
ExcelUtil<SparePartsInStorage> util = new ExcelUtil<SparePartsInStorage>(SparePartsInStorage.class);
public void export(HttpServletResponse response, EquSparepartsInOut equSparepartsInOut) {
List<EquSparepartsInOut> list = equSparepartsInOutService.selectEquSparepartsInOutList(equSparepartsInOut);
ExcelUtil<EquSparepartsInOut> util = new ExcelUtil<EquSparepartsInOut>(EquSparepartsInOut.class);
util.exportExcel(response, list, "备品备件出入库数据");
}
@ -61,9 +61,9 @@ public class SparePartsInOutStorageController extends BaseController {
*
*/
@RequiresPermissions("device:sparepartsInOutStorage:query")
@GetMapping(value = "/{rawOrderInSnId}")
public AjaxResult getInfo(@PathVariable("rawOrderInSnId") String rawOrderInSnId) {
return success(sparePartsInOutStorageService.selectSparePartsInStorageByRawOrderInSnId(rawOrderInSnId));
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") String id) {
return success(equSparepartsInOutService.selectEquSparepartsInOutById(id));
}
/**
@ -72,8 +72,8 @@ public class SparePartsInOutStorageController extends BaseController {
@RequiresPermissions("device:sparepartsInOutStorage:add")
@Log(title = "备品备件出入库", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody SparePartsInStorage sparePartsInStorage) {
return toAjax(sparePartsInOutStorageService.insertSparePartsInStorage(sparePartsInStorage));
public AjaxResult add(@RequestBody EquSparepartsInOut equSparepartsInOut) {
return equSparepartsInOutService.insertEquSparepartsInOut(equSparepartsInOut);
}
/**
@ -82,8 +82,8 @@ public class SparePartsInOutStorageController extends BaseController {
@RequiresPermissions("device:sparepartsInOutStorage:edit")
@Log(title = "备品备件出入库", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody SparePartsInStorage sparePartsInStorage) {
return toAjax(sparePartsInOutStorageService.updateSparePartsInStorage(sparePartsInStorage));
public AjaxResult edit(@RequestBody EquSparepartsInOut equSparepartsInOut) {
return equSparepartsInOutService.updateEquSparepartsInOut(equSparepartsInOut);
}
/**
@ -91,8 +91,8 @@ public class SparePartsInOutStorageController extends BaseController {
*/
@RequiresPermissions("device:sparepartsInOutStorage:remove")
@Log(title = "备品备件出入库", businessType = BusinessType.DELETE)
@DeleteMapping("/{rawOrderInSnIds}")
public AjaxResult remove(@PathVariable String[] rawOrderInSnIds) {
return toAjax(sparePartsInOutStorageService.deleteSparePartsInStorageByRawOrderInSnIds(rawOrderInSnIds));
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable String[] ids) {
return equSparepartsInOutService.deleteEquSparepartsInOutByIds(ids);
}
}

@ -0,0 +1,168 @@
package com.op.device.domain;
import java.math.BigDecimal;
import java.util.Date;
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;
/**
*
*
* @author Open Platform
* @date 2023-10-17
*/
public class EquSparepartsInOut extends BaseEntity {
private static final long serialVersionUID = 1L;
private String id;
@Excel(name = "出入库类型")
private String inOutType;
@Excel(name = "出入库单号")
private String orderNo;
@Excel(name = "备品备件号")
private String spareCode;
@Excel(name = "备品备件名称")
private String spareName;
@Excel(name = "数量")
private BigDecimal amount;
@Excel(name = "备用1")
private String attr1;
@Excel(name = "备用2")
private String attr2;
@Excel(name = "备用3")
private String attr3;
@Excel(name = "删除标记")
private String delFlag;
@Excel(name = "工厂号")
private String factoryCode;
///////////////////////////
private String storageId;
public void setId(String id) {
this.id = id;
}
public String getId() {
return id;
}
public void setInOutType(String inOutType) {
this.inOutType = inOutType;
}
public String getInOutType() {
return inOutType;
}
public void setOrderNo(String orderNo) {
this.orderNo = orderNo;
}
public String getOrderNo() {
return orderNo;
}
public void setSpareCode(String spareCode) {
this.spareCode = spareCode;
}
public String getSpareCode() {
return spareCode;
}
public void setSpareName(String spareName) {
this.spareName = spareName;
}
public String getSpareName() {
return spareName;
}
public void setAmount(BigDecimal amount) {
this.amount = amount;
}
public BigDecimal getAmount() {
return amount;
}
public void setAttr1(String attr1) {
this.attr1 = attr1;
}
public String getAttr1() {
return attr1;
}
public void setAttr2(String attr2) {
this.attr2 = attr2;
}
public String getAttr2() {
return attr2;
}
public void setAttr3(String attr3) {
this.attr3 = attr3;
}
public String getAttr3() {
return attr3;
}
public void setFactoryCode(String factoryCode) {
this.factoryCode = factoryCode;
}
public String getFactoryCode() {
return factoryCode;
}
public void setDelFlag(String delFlag) {
this.delFlag = delFlag;
}
public String getDelFlag() {
return delFlag;
}
/////
public void setStorageId(String storageId) {
this.storageId = storageId;
}
public String getStorageId() {
return storageId;
}
@Override
public String toString() {
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("inOutType", getInOutType())
.append("orderNo", getOrderNo())
.append("spareCode", getSpareCode())
.append("spareName", getSpareName())
.append("amount", getAmount())
.append("attr1", getAttr1())
.append("attr2", getAttr2())
.append("attr3", getAttr3())
.append("delFlag", getDelFlag())
.append("factoryCode", getFactoryCode())
.toString();
}
}

@ -1,433 +0,0 @@
package com.op.device.domain;
import java.math.BigDecimal;
import java.util.Date;
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;
/**
* wms_raw_order_in_sn
*
* @author Open Platform
* @date 2023-10-17
*/
public class SparePartsInStorage extends BaseEntity {
private static final long serialVersionUID = 1L;
/**
*
*/
private String rawOrderInSnId;
/**
*
*/
@Excel(name = "仓库编码")
private String whCode;
/**
*
*/
@Excel(name = "库区编码")
private String waCode;
/**
*
*/
@Excel(name = "库位编码")
private String wlCode;
/**
*
*/
@Excel(name = "入库单号")
private String orderNo;
/**
*
*/
@Excel(name = "采购订单号")
private String poNo;
/**
*
*/
@Excel(name = "采购订单行项目")
private String poLine;
/**
*
*/
@Excel(name = "物料号")
private String materialCode;
/**
*
*/
@Excel(name = "物料描述")
private String materialDesc;
/**
* sn/LPN
*/
@Excel(name = "sn/LPN")
private String sn;
/**
*
*/
@Excel(name = "数量")
private BigDecimal amount;
/**
* 1
*/
@Excel(name = "备用1")
private String userDefined1;
/**
* 2
*/
@Excel(name = "备用2")
private String userDefined2;
/**
* 3
*/
@Excel(name = "备用3")
private String userDefined3;
/**
* 4
*/
@Excel(name = "备用4")
private String userDefined4;
/**
* 5
*/
@Excel(name = "备用5")
private String userDefined5;
/**
* 6
*/
@Excel(name = "备用6")
private String userDefined6;
/**
* 7
*/
@Excel(name = "备用7")
private String userDefined7;
/**
* 8
*/
@Excel(name = "备用8")
private String userDefined8;
/**
* 9
*/
@Excel(name = "备用9")
private String userDefined9;
/**
* 10
*/
@Excel(name = "备用10")
private String userDefined10;
/**
*
*/
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "创建时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date gmtCreate;
/**
*
*/
@Excel(name = "最后更新人")
private String lastModifiedBy;
/**
*
*/
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "最后更新时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date gmtModified;
/**
*
*/
@Excel(name = "有效标记")
private String activeFlag;
/**
* $column.columnComment
*/
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
private String factoryCode;
/**
* $column.columnComment
*/
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
private String sapFactoryCode;
public void setRawOrderInSnId(String rawOrderInSnId) {
this.rawOrderInSnId = rawOrderInSnId;
}
public String getRawOrderInSnId() {
return rawOrderInSnId;
}
public void setWhCode(String whCode) {
this.whCode = whCode;
}
public String getWhCode() {
return whCode;
}
public void setWaCode(String waCode) {
this.waCode = waCode;
}
public String getWaCode() {
return waCode;
}
public void setWlCode(String wlCode) {
this.wlCode = wlCode;
}
public String getWlCode() {
return wlCode;
}
public void setOrderNo(String orderNo) {
this.orderNo = orderNo;
}
public String getOrderNo() {
return orderNo;
}
public void setPoNo(String poNo) {
this.poNo = poNo;
}
public String getPoNo() {
return poNo;
}
public void setPoLine(String poLine) {
this.poLine = poLine;
}
public String getPoLine() {
return poLine;
}
public void setMaterialCode(String materialCode) {
this.materialCode = materialCode;
}
public String getMaterialCode() {
return materialCode;
}
public void setMaterialDesc(String materialDesc) {
this.materialDesc = materialDesc;
}
public String getMaterialDesc() {
return materialDesc;
}
public void setSn(String sn) {
this.sn = sn;
}
public String getSn() {
return sn;
}
public void setAmount(BigDecimal amount) {
this.amount = amount;
}
public BigDecimal getAmount() {
return amount;
}
public void setUserDefined1(String userDefined1) {
this.userDefined1 = userDefined1;
}
public String getUserDefined1() {
return userDefined1;
}
public void setUserDefined2(String userDefined2) {
this.userDefined2 = userDefined2;
}
public String getUserDefined2() {
return userDefined2;
}
public void setUserDefined3(String userDefined3) {
this.userDefined3 = userDefined3;
}
public String getUserDefined3() {
return userDefined3;
}
public void setUserDefined4(String userDefined4) {
this.userDefined4 = userDefined4;
}
public String getUserDefined4() {
return userDefined4;
}
public void setUserDefined5(String userDefined5) {
this.userDefined5 = userDefined5;
}
public String getUserDefined5() {
return userDefined5;
}
public void setUserDefined6(String userDefined6) {
this.userDefined6 = userDefined6;
}
public String getUserDefined6() {
return userDefined6;
}
public void setUserDefined7(String userDefined7) {
this.userDefined7 = userDefined7;
}
public String getUserDefined7() {
return userDefined7;
}
public void setUserDefined8(String userDefined8) {
this.userDefined8 = userDefined8;
}
public String getUserDefined8() {
return userDefined8;
}
public void setUserDefined9(String userDefined9) {
this.userDefined9 = userDefined9;
}
public String getUserDefined9() {
return userDefined9;
}
public void setUserDefined10(String userDefined10) {
this.userDefined10 = userDefined10;
}
public String getUserDefined10() {
return userDefined10;
}
public void setGmtCreate(Date gmtCreate) {
this.gmtCreate = gmtCreate;
}
public Date getGmtCreate() {
return gmtCreate;
}
public void setLastModifiedBy(String lastModifiedBy) {
this.lastModifiedBy = lastModifiedBy;
}
public String getLastModifiedBy() {
return lastModifiedBy;
}
public void setGmtModified(Date gmtModified) {
this.gmtModified = gmtModified;
}
public Date getGmtModified() {
return gmtModified;
}
public void setActiveFlag(String activeFlag) {
this.activeFlag = activeFlag;
}
public String getActiveFlag() {
return activeFlag;
}
public void setFactoryCode(String factoryCode) {
this.factoryCode = factoryCode;
}
public String getFactoryCode() {
return factoryCode;
}
public void setSapFactoryCode(String sapFactoryCode) {
this.sapFactoryCode = sapFactoryCode;
}
public String getSapFactoryCode() {
return sapFactoryCode;
}
@Override
public String toString() {
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
.append("rawOrderInSnId", getRawOrderInSnId())
.append("whCode", getWhCode())
.append("waCode", getWaCode())
.append("wlCode", getWlCode())
.append("orderNo", getOrderNo())
.append("poNo", getPoNo())
.append("poLine", getPoLine())
.append("materialCode", getMaterialCode())
.append("materialDesc", getMaterialDesc())
.append("sn", getSn())
.append("amount", getAmount())
.append("userDefined1", getUserDefined1())
.append("userDefined2", getUserDefined2())
.append("userDefined3", getUserDefined3())
.append("userDefined4", getUserDefined4())
.append("userDefined5", getUserDefined5())
.append("userDefined6", getUserDefined6())
.append("userDefined7", getUserDefined7())
.append("userDefined8", getUserDefined8())
.append("userDefined9", getUserDefined9())
.append("userDefined10", getUserDefined10())
.append("createBy", getCreateBy())
.append("gmtCreate", getGmtCreate())
.append("lastModifiedBy", getLastModifiedBy())
.append("gmtModified", getGmtModified())
.append("activeFlag", getActiveFlag())
.append("factoryCode", getFactoryCode())
.append("sapFactoryCode", getSapFactoryCode())
.toString();
}
}

@ -0,0 +1,63 @@
package com.op.device.mapper;
import java.util.List;
import com.op.device.domain.EquSparepartsInOut;
/**
* Mapper
*
* @author Open Platform
* @date 2023-10-17
*/
public interface EquSparepartsInOutMapper {
/**
*
*
* @param id
* @return
*/
public EquSparepartsInOut selectEquSparepartsInOutById(String id);
/**
*
*
* @param equSparepartsInOut
* @return
*/
public List<EquSparepartsInOut> selectEquSparepartsInOutList(EquSparepartsInOut equSparepartsInOut);
/**
*
*
* @param equSparepartsInOut
* @return
*/
public int insertEquSparepartsInOut(EquSparepartsInOut equSparepartsInOut);
/**
*
*
* @param equSparepartsInOut
* @return
*/
public int updateEquSparepartsInOut(EquSparepartsInOut equSparepartsInOut);
/**
*
*
* @param id
* @return
*/
public int deleteEquSparepartsInOutById(String id);
/**
*
*
* @param ids
* @return
*/
public int deleteEquSparepartsInOutByIds(String[] ids);
int selectSerialNumber();
}

@ -1,61 +0,0 @@
package com.op.device.mapper;
import java.util.List;
import com.op.device.domain.SparePartsInStorage;
/**
* Mapper
*
* @author Open Platform
* @date 2023-10-17
*/
public interface SparePartsInOutStorageMapper {
/**
*
*
* @param rawOrderInSnId
* @return
*/
public SparePartsInStorage selectSparePartsInStorageByRawOrderInSnId(String rawOrderInSnId);
/**
*
*
* @param sparePartsInStorage
* @return
*/
public List<SparePartsInStorage> selectSparePartsInStorageList(SparePartsInStorage sparePartsInStorage);
/**
*
*
* @param sparePartsInStorage
* @return
*/
public int insertSparePartsInStorage(SparePartsInStorage sparePartsInStorage);
/**
*
*
* @param sparePartsInStorage
* @return
*/
public int updateSparePartsInStorage(SparePartsInStorage sparePartsInStorage);
/**
*
*
* @param rawOrderInSnId
* @return
*/
public int deleteSparePartsInStorageByRawOrderInSnId(String rawOrderInSnId);
/**
*
*
* @param rawOrderInSnIds
* @return
*/
public int deleteSparePartsInStorageByRawOrderInSnIds(String[] rawOrderInSnIds);
}

@ -2,7 +2,8 @@ package com.op.device.service;
import java.util.List;
import com.op.device.domain.SparePartsInStorage;
import com.op.common.core.web.domain.AjaxResult;
import com.op.device.domain.EquSparepartsInOut;
/**
* Service
@ -10,14 +11,14 @@ import com.op.device.domain.SparePartsInStorage;
* @author Open Platform
* @date 2023-10-17
*/
public interface ISparePartsInOutStorageService {
public interface IEquSparepartsInOutService {
/**
*
*
* @param rawOrderInSnId
* @param Id
* @return
*/
public SparePartsInStorage selectSparePartsInStorageByRawOrderInSnId(String rawOrderInSnId);
public EquSparepartsInOut selectEquSparepartsInOutById(String Id);
/**
*
@ -25,7 +26,7 @@ public interface ISparePartsInOutStorageService {
* @param sparePartsInStorage
* @return
*/
public List<SparePartsInStorage> selectSparePartsInStorageList(SparePartsInStorage sparePartsInStorage);
public List<EquSparepartsInOut> selectEquSparepartsInOutList(EquSparepartsInOut sparePartsInStorage);
/**
*
@ -33,7 +34,7 @@ public interface ISparePartsInOutStorageService {
* @param sparePartsInStorage
* @return
*/
public int insertSparePartsInStorage(SparePartsInStorage sparePartsInStorage);
public AjaxResult insertEquSparepartsInOut(EquSparepartsInOut sparePartsInStorage);
/**
*
@ -41,21 +42,21 @@ public interface ISparePartsInOutStorageService {
* @param sparePartsInStorage
* @return
*/
public int updateSparePartsInStorage(SparePartsInStorage sparePartsInStorage);
public AjaxResult updateEquSparepartsInOut(EquSparepartsInOut sparePartsInStorage);
/**
*
*
* @param rawOrderInSnIds
* @param ids
* @return
*/
public int deleteSparePartsInStorageByRawOrderInSnIds(String[] rawOrderInSnIds);
public AjaxResult deleteEquSparepartsInOutByIds(String[] ids);
/**
*
*
* @param rawOrderInSnId
* @param id
* @return
*/
public int deleteSparePartsInStorageByRawOrderInSnId(String rawOrderInSnId);
public AjaxResult deleteEquSparepartsInOutById(String id);
}

@ -0,0 +1,212 @@
package com.op.device.service.impl;
import java.math.BigDecimal;
import java.util.List;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.op.common.core.utils.DateUtils;
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.device.domain.SparePartsLedger;
import com.op.device.mapper.SparePartsLedgerMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.op.device.mapper.EquSparepartsInOutMapper;
import com.op.device.domain.EquSparepartsInOut;
import com.op.device.service.IEquSparepartsInOutService;
/**
* Service
*
* @author Open Platform
* @date 2023-10-17
*/
@Service
public class EquSparepartsInOutImpl implements IEquSparepartsInOutService {
@Autowired
private EquSparepartsInOutMapper equSparepartsInOutMapper;
@Autowired
private SparePartsLedgerMapper sparePartsLedgerMapper;
/**
*
*
* @param id
* @return
*/
@Override
@DS("#header.poolName")
public EquSparepartsInOut selectEquSparepartsInOutById(String id) {
return equSparepartsInOutMapper.selectEquSparepartsInOutById(id);
}
/**
*
*
* @param equSparepartsInOut
* @return
*/
@Override
@DS("#header.poolName")
public List<EquSparepartsInOut> selectEquSparepartsInOutList(EquSparepartsInOut equSparepartsInOut) {
return equSparepartsInOutMapper.selectEquSparepartsInOutList(equSparepartsInOut);
}
/**
*
*
* @param equSparepartsInOut
* @return
*/
@Override
@DS("#header.poolName")
public AjaxResult insertEquSparepartsInOut(EquSparepartsInOut equSparepartsInOut) {
equSparepartsInOut.setId(IdUtils.fastSimpleUUID());
equSparepartsInOut.setCreateTime(DateUtils.getNowDate());
equSparepartsInOut.setCreateBy(SecurityUtils.getUsername());
SparePartsLedger sparePartsLedger = sparePartsLedgerMapper.selectSparePartsLedgerByStorageId(equSparepartsInOut.getStorageId());
if(sparePartsLedger != null){
if(equSparepartsInOut.getInOutType().equals("type_in")){//入库
if(sparePartsLedger.getAmount() != null){
BigDecimal result = sparePartsLedger.getAmount().add(equSparepartsInOut.getAmount());
//修改
sparePartsLedger.setAmount(result);
sparePartsLedger.setLastModifiedBy(SecurityUtils.getUsername());//最后更新人
sparePartsLedger.setGmtModified(DateUtils.getNowDate());//最后更新时间
sparePartsLedgerMapper.updateSparePartsLedger(sparePartsLedger);
}
}else{//出库
if(sparePartsLedger.getAmount() != null){
if(sparePartsLedger.getAmount().compareTo(equSparepartsInOut.getAmount()) <= 0){
return AjaxResult.error("出库数量大于库存数量!");
}else{
BigDecimal result = sparePartsLedger.getAmount().subtract(equSparepartsInOut.getAmount());
//修改
sparePartsLedger.setAmount(result);
sparePartsLedger.setLastModifiedBy(SecurityUtils.getUsername());//最后更新人
sparePartsLedger.setGmtModified(DateUtils.getNowDate());//最后更新时间
sparePartsLedgerMapper.updateSparePartsLedger(sparePartsLedger);
}
}
}
}else{
return AjaxResult.error("不存在此备品备件");
}
// 获取流水号
String date = DateUtils.dateTimeNow(DateUtils.YYYYMMDD);
String serialNum = String.format("%04d", equSparepartsInOutMapper.selectSerialNumber());
equSparepartsInOut.setOrderNo(date + serialNum);
equSparepartsInOutMapper.insertEquSparepartsInOut(equSparepartsInOut);
return AjaxResult.success("新增成功!");
}
/**
*
*
* @param equSparepartsInOut
* @return
*/
@Override
@DS("#header.poolName")
public AjaxResult updateEquSparepartsInOut(EquSparepartsInOut equSparepartsInOut) {
equSparepartsInOut.setUpdateTime(DateUtils.getNowDate());
equSparepartsInOut.setUpdateBy(SecurityUtils.getUsername());
equSparepartsInOutMapper.updateEquSparepartsInOut(equSparepartsInOut);
return AjaxResult.success("修改成功");
}
/**
*
*
* @param ids
* @return
*/
@Override
@DS("#header.poolName")
public AjaxResult deleteEquSparepartsInOutByIds(String[] ids) {
//查询原本的类型和数量 加回去
for(String id:ids){
EquSparepartsInOut equSparepartsInOut = equSparepartsInOutMapper.selectEquSparepartsInOutById(id);
SparePartsLedger sparePartsLedger = sparePartsLedgerMapper.selectSparePartsLedgerByStorageId(equSparepartsInOut.getStorageId());
if(sparePartsLedger != null){
if(equSparepartsInOut.getInOutType().equals("type_in")){//入库
if(sparePartsLedger.getAmount() != null){
if(sparePartsLedger.getAmount().compareTo(equSparepartsInOut.getAmount()) <= 0){
return AjaxResult.error("备品备件台账的备品备件数量小于当时的入库数量!");
}else{
BigDecimal result = sparePartsLedger.getAmount().subtract(equSparepartsInOut.getAmount());
//修改
sparePartsLedger.setAmount(result);
sparePartsLedger.setLastModifiedBy(SecurityUtils.getUsername());//最后更新人
sparePartsLedger.setGmtModified(DateUtils.getNowDate());//最后更新时间
sparePartsLedgerMapper.updateSparePartsLedger(sparePartsLedger);
}
}
}else{//出库
if(sparePartsLedger.getAmount() != null){
BigDecimal result = sparePartsLedger.getAmount().add(equSparepartsInOut.getAmount());
//修改
sparePartsLedger.setAmount(result);
sparePartsLedger.setLastModifiedBy(SecurityUtils.getUsername());//最后更新人
sparePartsLedger.setGmtModified(DateUtils.getNowDate());//最后更新时间
sparePartsLedgerMapper.updateSparePartsLedger(sparePartsLedger);
}
}
}else{
return AjaxResult.error("不存在此备品备件");
}
}
equSparepartsInOutMapper.deleteEquSparepartsInOutByIds(ids);
return AjaxResult.success("删除成功");
}
/**
*
*
* @param id
* @return
*/
@Override
@DS("#header.poolName")
public AjaxResult deleteEquSparepartsInOutById(String id) {
EquSparepartsInOut equSparepartsInOut = equSparepartsInOutMapper.selectEquSparepartsInOutById(id);
SparePartsLedger sparePartsLedger = sparePartsLedgerMapper.selectSparePartsLedgerByStorageId(equSparepartsInOut.getStorageId());
if(sparePartsLedger != null){
if(equSparepartsInOut.getInOutType().equals("type_in")){//入库
if(sparePartsLedger.getAmount() != null){
if(sparePartsLedger.getAmount().compareTo(equSparepartsInOut.getAmount()) <= 0){
return AjaxResult.error("备品备件台账的备品备件数量小于当时的入库数量!");
}else{
BigDecimal result = sparePartsLedger.getAmount().subtract(equSparepartsInOut.getAmount());
//修改
sparePartsLedger.setAmount(result);
sparePartsLedger.setLastModifiedBy(SecurityUtils.getUsername());//最后更新人
sparePartsLedger.setGmtModified(DateUtils.getNowDate());//最后更新时间
sparePartsLedgerMapper.updateSparePartsLedger(sparePartsLedger);
}
}
}else{//出库
if(sparePartsLedger.getAmount() != null){
BigDecimal result = sparePartsLedger.getAmount().add(equSparepartsInOut.getAmount());
//修改
sparePartsLedger.setAmount(result);
sparePartsLedger.setLastModifiedBy(SecurityUtils.getUsername());//最后更新人
sparePartsLedger.setGmtModified(DateUtils.getNowDate());//最后更新时间
sparePartsLedgerMapper.updateSparePartsLedger(sparePartsLedger);
}
}
}else{
return AjaxResult.error("不存在此备品备件");
}
equSparepartsInOutMapper.deleteEquSparepartsInOutById(id);
return AjaxResult.success("删除成功");
}
}

@ -1,95 +0,0 @@
package com.op.device.service.impl;
import java.util.List;
import com.baomidou.dynamic.datasource.annotation.DS;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.op.device.mapper.SparePartsInOutStorageMapper;
import com.op.device.domain.SparePartsInStorage;
import com.op.device.service.ISparePartsInOutStorageService;
/**
* Service
*
* @author Open Platform
* @date 2023-10-17
*/
@Service
public class SparePartsInOutStorageServiceImpl implements ISparePartsInOutStorageService {
@Autowired
private SparePartsInOutStorageMapper sparePartsInOutStorageMapper;
/**
*
*
* @param rawOrderInSnId
* @return
*/
@Override
@DS("#header.poolName")
public SparePartsInStorage selectSparePartsInStorageByRawOrderInSnId(String rawOrderInSnId) {
return sparePartsInOutStorageMapper.selectSparePartsInStorageByRawOrderInSnId(rawOrderInSnId);
}
/**
*
*
* @param sparePartsInStorage
* @return
*/
@Override
@DS("#header.poolName")
public List<SparePartsInStorage> selectSparePartsInStorageList(SparePartsInStorage sparePartsInStorage) {
return sparePartsInOutStorageMapper.selectSparePartsInStorageList(sparePartsInStorage);
}
/**
*
*
* @param sparePartsInStorage
* @return
*/
@Override
@DS("#header.poolName")
public int insertSparePartsInStorage(SparePartsInStorage sparePartsInStorage) {
return sparePartsInOutStorageMapper.insertSparePartsInStorage(sparePartsInStorage);
}
/**
*
*
* @param sparePartsInStorage
* @return
*/
@Override
@DS("#header.poolName")
public int updateSparePartsInStorage(SparePartsInStorage sparePartsInStorage) {
return sparePartsInOutStorageMapper.updateSparePartsInStorage(sparePartsInStorage);
}
/**
*
*
* @param rawOrderInSnIds
* @return
*/
@Override
@DS("#header.poolName")
public int deleteSparePartsInStorageByRawOrderInSnIds(String[] rawOrderInSnIds) {
return sparePartsInOutStorageMapper.deleteSparePartsInStorageByRawOrderInSnIds(rawOrderInSnIds);
}
/**
*
*
* @param rawOrderInSnId
* @return
*/
@Override
@DS("#header.poolName")
public int deleteSparePartsInStorageByRawOrderInSnId(String rawOrderInSnId) {
return sparePartsInOutStorageMapper.deleteSparePartsInStorageByRawOrderInSnId(rawOrderInSnId);
}
}

@ -0,0 +1,135 @@
<?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.device.mapper.EquSparepartsInOutMapper">
<resultMap type="EquSparepartsInOut" id="EquSparepartsInOutResult">
<result property="id" column="id"/>
<result property="inOutType" column="in_out_type"/>
<result property="orderNo" column="order_no"/>
<result property="spareCode" column="spare_code"/>
<result property="spareName" column="spare_name"/>
<result property="amount" column="amount"/>
<result property="attr1" column="attr1"/>
<result property="attr2" column="attr2"/>
<result property="attr3" column="attr3"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="updateBy" column="update_by"/>
<result property="updateTime" column="update_time"/>
<result property="delFlag" column="del_flag"/>
<result property="factoryCode" column="factory_code"/>
<result property="storageId" column="storage_id" />
</resultMap>
<sql id="selectEquSparepartsInOutVo">
select id, in_out_type, order_no,spare_code, spare_name ,amount, attr1, attr2, attr3, create_by, create_time, update_by, update_time, del_flag, factory_code,storage_id from equ_spareparts_in_out
</sql>
<select id="selectEquSparepartsInOutList" parameterType="EquSparepartsInOut" resultMap="EquSparepartsInOutResult">
<include refid="selectEquSparepartsInOutVo"/>
<where>
<if test="inOutType != null and inOutType != ''">and in_out_type = #{inOutType}</if>
<if test="orderNo != null and orderNo != ''">and order_no = #{orderNo}</if>
<if test="spareCode != null and spareCode != ''">and spare_code = #{spareCode}</if>
<if test="spareName != null and spareName != ''">and spare_name = #{spareName}</if>
<if test="amount != null ">and amount = #{amount}</if>
<if test="attr1 != null and attr1 != ''">and attr1 = #{attr1}</if>
<if test="attr2 != null and attr2 != ''">and attr2 = #{attr2}</if>
<if test="attr3 != null and attr3 != ''">and attr3 = #{attr3}</if>
<if test="createTime != null ">and create_time = #{createTime}</if>
<if test="updateBy != null and updateBy != ''">and update_by = #{updateBy}</if>
<if test="updateTime != null ">and update_time = #{updateTime}</if>
<if test="delFlag != null and delFlag != ''">and del_flag = #{delFlag}</if>
<if test="factoryCode != null and factoryCode != ''">and factory_code = #{factoryCode}</if>
</where>
</select>
<select id="selectEquSparepartsInOutById" parameterType="String" resultMap="EquSparepartsInOutResult">
<include refid="selectEquSparepartsInOutVo"/>
where id = #{id}
</select>
<insert id="insertEquSparepartsInOut" parameterType="EquSparepartsInOut">
insert into equ_spareparts_in_out
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
<if test="inOutType != null">in_out_type,</if>
<if test="orderNo != null">order_no,</if>
<if test="spareCode != null">spare_code,</if>
<if test="spareName != null">spare_name,</if>
amount,
<if test="attr1 != null">attr11,</if>
<if test="attr2 != null">attr12,</if>
<if test="attr3 != null">attr13,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="delFlag != null">del_flag,</if>
<if test="factoryCode != null">factory_code,</if>
<if test="storageId != null and storageId != ''">storage_id,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if>
<if test="inOutType != null">#{inOutType},</if>
<if test="orderNo != null">#{orderNo},</if>
<if test="spareCode != null">#{spareCode},</if>
<if test="spareName != null">#{spareName},</if>
#{amount},
<if test="attr1 != null">#{attr1},</if>
<if test="attr2 != null">#{attr2},</if>
<if test="attr3 != null">#{attr3},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="delFlag != null">#{delFlag},</if>
<if test="factoryCode != null">#{factoryCode},</if>
<if test="storageId != null and storageId != ''">#{storageId},</if>
</trim>
</insert>
<update id="updateEquSparepartsInOut" parameterType="EquSparepartsInOut">
update equ_spareparts_in_out
<trim prefix="SET" suffixOverrides=",">
<if test="inOutType != null">in_out_type = #{inOutType},</if>
<if test="orderNo != null">order_no = #{orderNo},</if>
<if test="spareCode != null">spare_code = #{spareCode},</if>
<if test="spareName != null">spare_name = #{spareName},</if>
<if test="amount != null">amount = #{amount},</if>
<if test="attr1 != null">attr1 = #{attr1},</if>
<if test="attr2 != null">attr2 = #{attr2},</if>
<if test="attr3 != null">attr3 = #{attr3},</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>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="delFlag != null">del_flag = #{delFlag},</if>
<if test="factoryCode != null">factory_code = #{factoryCode},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteEquSparepartsInOutById" parameterType="String">
update equ_spareparts_in_out
set del_flag = '1'
where id = #{id}
</delete>
<delete id="deleteEquSparepartsInOutByIds" parameterType="String">
update equ_spareparts_in_out
set del_flag = '1'
where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<select id="selectSerialNumber" resultType="java.lang.Integer">
SELECT COUNT(id)+1 AS serialNum
FROM equ_spareparts_in_out
WHERE CONVERT(date, GETDATE()) = CONVERT(date,create_time)
</select>
</mapper>

@ -1,188 +0,0 @@
<?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.device.mapper.SparePartsInOutStorageMapper">
<resultMap type="SparePartsInStorage" id="SparePartsInStorageResult">
<result property="rawOrderInSnId" column="raw_order_in_sn_id"/>
<result property="whCode" column="wh_code"/>
<result property="waCode" column="wa_code"/>
<result property="wlCode" column="wl_code"/>
<result property="orderNo" column="order_no"/>
<result property="poNo" column="po_no"/>
<result property="poLine" column="po_line"/>
<result property="materialCode" column="material_code"/>
<result property="materialDesc" column="material_desc"/>
<result property="sn" column="sn"/>
<result property="amount" column="amount"/>
<result property="userDefined1" column="user_defined1"/>
<result property="userDefined2" column="user_defined2"/>
<result property="userDefined3" column="user_defined3"/>
<result property="userDefined4" column="user_defined4"/>
<result property="userDefined5" column="user_defined5"/>
<result property="userDefined6" column="user_defined6"/>
<result property="userDefined7" column="user_defined7"/>
<result property="userDefined8" column="user_defined8"/>
<result property="userDefined9" column="user_defined9"/>
<result property="userDefined10" column="user_defined10"/>
<result property="createBy" column="create_by"/>
<result property="gmtCreate" column="gmt_create"/>
<result property="lastModifiedBy" column="last_modified_by"/>
<result property="gmtModified" column="gmt_modified"/>
<result property="activeFlag" column="active_flag"/>
<result property="factoryCode" column="factory_code"/>
<result property="sapFactoryCode" column="sap_factory_code"/>
</resultMap>
<sql id="selectSparePartsInStorageVo">
select raw_order_in_sn_id, wh_code, wa_code, wl_code, order_no, po_no, po_line, material_code, material_desc, sn, amount, user_defined1, user_defined2, user_defined3, user_defined4, user_defined5, user_defined6, user_defined7, user_defined8, user_defined9, user_defined10, create_by, gmt_create, last_modified_by, gmt_modified, active_flag, factory_code, sap_factory_code from wms_raw_order_in_sn
</sql>
<select id="selectSparePartsInStorageList" parameterType="SparePartsInStorage"
resultMap="SparePartsInStorageResult">
<include refid="selectSparePartsInStorageVo"/>
<where>
<if test="whCode != null and whCode != ''">and wh_code = #{whCode}</if>
<if test="waCode != null and waCode != ''">and wa_code = #{waCode}</if>
<if test="wlCode != null and wlCode != ''">and wl_code = #{wlCode}</if>
<if test="orderNo != null and orderNo != ''">and order_no = #{orderNo}</if>
<if test="poNo != null and poNo != ''">and po_no = #{poNo}</if>
<if test="poLine != null and poLine != ''">and po_line = #{poLine}</if>
<if test="materialCode != null and materialCode != ''">and material_code = #{materialCode}</if>
<if test="materialDesc != null and materialDesc != ''">and material_desc = #{materialDesc}</if>
<if test="sn != null and sn != ''">and sn = #{sn}</if>
<if test="amount != null ">and amount = #{amount}</if>
<if test="userDefined1 != null and userDefined1 != ''">and user_defined1 = #{userDefined1}</if>
<if test="userDefined2 != null and userDefined2 != ''">and user_defined2 = #{userDefined2}</if>
<if test="userDefined3 != null and userDefined3 != ''">and user_defined3 = #{userDefined3}</if>
<if test="userDefined4 != null and userDefined4 != ''">and user_defined4 = #{userDefined4}</if>
<if test="userDefined5 != null and userDefined5 != ''">and user_defined5 = #{userDefined5}</if>
<if test="userDefined6 != null and userDefined6 != ''">and user_defined6 = #{userDefined6}</if>
<if test="userDefined7 != null and userDefined7 != ''">and user_defined7 = #{userDefined7}</if>
<if test="userDefined8 != null and userDefined8 != ''">and user_defined8 = #{userDefined8}</if>
<if test="userDefined9 != null and userDefined9 != ''">and user_defined9 = #{userDefined9}</if>
<if test="userDefined10 != null and userDefined10 != ''">and user_defined10 = #{userDefined10}</if>
<if test="gmtCreate != null ">and gmt_create = #{gmtCreate}</if>
<if test="lastModifiedBy != null and lastModifiedBy != ''">and last_modified_by = #{lastModifiedBy}</if>
<if test="gmtModified != null ">and gmt_modified = #{gmtModified}</if>
<if test="activeFlag != null and activeFlag != ''">and active_flag = #{activeFlag}</if>
<if test="factoryCode != null and factoryCode != ''">and factory_code = #{factoryCode}</if>
<if test="sapFactoryCode != null and sapFactoryCode != ''">and sap_factory_code = #{sapFactoryCode}</if>
</where>
</select>
<select id="selectSparePartsInStorageByRawOrderInSnId" parameterType="String" resultMap="SparePartsInStorageResult">
<include refid="selectSparePartsInStorageVo"/>
where raw_order_in_sn_id = #{rawOrderInSnId}
</select>
<insert id="insertSparePartsInStorage" parameterType="SparePartsInStorage">
insert into wms_raw_order_in_sn
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="rawOrderInSnId != null">raw_order_in_sn_id,</if>
<if test="whCode != null">wh_code,</if>
<if test="waCode != null">wa_code,</if>
<if test="wlCode != null">wl_code,</if>
<if test="orderNo != null">order_no,</if>
<if test="poNo != null">po_no,</if>
<if test="poLine != null">po_line,</if>
<if test="materialCode != null">material_code,</if>
<if test="materialDesc != null">material_desc,</if>
<if test="sn != null">sn,</if>
<if test="amount != null">amount,</if>
<if test="userDefined1 != null">user_defined1,</if>
<if test="userDefined2 != null">user_defined2,</if>
<if test="userDefined3 != null">user_defined3,</if>
<if test="userDefined4 != null">user_defined4,</if>
<if test="userDefined5 != null">user_defined5,</if>
<if test="userDefined6 != null">user_defined6,</if>
<if test="userDefined7 != null">user_defined7,</if>
<if test="userDefined8 != null">user_defined8,</if>
<if test="userDefined9 != null">user_defined9,</if>
<if test="userDefined10 != null">user_defined10,</if>
<if test="createBy != null">create_by,</if>
<if test="gmtCreate != null">gmt_create,</if>
<if test="lastModifiedBy != null">last_modified_by,</if>
<if test="gmtModified != null">gmt_modified,</if>
<if test="activeFlag != null">active_flag,</if>
<if test="factoryCode != null">factory_code,</if>
<if test="sapFactoryCode != null">sap_factory_code,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="rawOrderInSnId != null">#{rawOrderInSnId},</if>
<if test="whCode != null">#{whCode},</if>
<if test="waCode != null">#{waCode},</if>
<if test="wlCode != null">#{wlCode},</if>
<if test="orderNo != null">#{orderNo},</if>
<if test="poNo != null">#{poNo},</if>
<if test="poLine != null">#{poLine},</if>
<if test="materialCode != null">#{materialCode},</if>
<if test="materialDesc != null">#{materialDesc},</if>
<if test="sn != null">#{sn},</if>
<if test="amount != null">#{amount},</if>
<if test="userDefined1 != null">#{userDefined1},</if>
<if test="userDefined2 != null">#{userDefined2},</if>
<if test="userDefined3 != null">#{userDefined3},</if>
<if test="userDefined4 != null">#{userDefined4},</if>
<if test="userDefined5 != null">#{userDefined5},</if>
<if test="userDefined6 != null">#{userDefined6},</if>
<if test="userDefined7 != null">#{userDefined7},</if>
<if test="userDefined8 != null">#{userDefined8},</if>
<if test="userDefined9 != null">#{userDefined9},</if>
<if test="userDefined10 != null">#{userDefined10},</if>
<if test="createBy != null">#{createBy},</if>
<if test="gmtCreate != null">#{gmtCreate},</if>
<if test="lastModifiedBy != null">#{lastModifiedBy},</if>
<if test="gmtModified != null">#{gmtModified},</if>
<if test="activeFlag != null">#{activeFlag},</if>
<if test="factoryCode != null">#{factoryCode},</if>
<if test="sapFactoryCode != null">#{sapFactoryCode},</if>
</trim>
</insert>
<update id="updateSparePartsInStorage" parameterType="SparePartsInStorage">
update wms_raw_order_in_sn
<trim prefix="SET" suffixOverrides=",">
<if test="whCode != null">wh_code = #{whCode},</if>
<if test="waCode != null">wa_code = #{waCode},</if>
<if test="wlCode != null">wl_code = #{wlCode},</if>
<if test="orderNo != null">order_no = #{orderNo},</if>
<if test="poNo != null">po_no = #{poNo},</if>
<if test="poLine != null">po_line = #{poLine},</if>
<if test="materialCode != null">material_code = #{materialCode},</if>
<if test="materialDesc != null">material_desc = #{materialDesc},</if>
<if test="sn != null">sn = #{sn},</if>
<if test="amount != null">amount = #{amount},</if>
<if test="userDefined1 != null">user_defined1 = #{userDefined1},</if>
<if test="userDefined2 != null">user_defined2 = #{userDefined2},</if>
<if test="userDefined3 != null">user_defined3 = #{userDefined3},</if>
<if test="userDefined4 != null">user_defined4 = #{userDefined4},</if>
<if test="userDefined5 != null">user_defined5 = #{userDefined5},</if>
<if test="userDefined6 != null">user_defined6 = #{userDefined6},</if>
<if test="userDefined7 != null">user_defined7 = #{userDefined7},</if>
<if test="userDefined8 != null">user_defined8 = #{userDefined8},</if>
<if test="userDefined9 != null">user_defined9 = #{userDefined9},</if>
<if test="userDefined10 != null">user_defined10 = #{userDefined10},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="gmtCreate != null">gmt_create = #{gmtCreate},</if>
<if test="lastModifiedBy != null">last_modified_by = #{lastModifiedBy},</if>
<if test="gmtModified != null">gmt_modified = #{gmtModified},</if>
<if test="activeFlag != null">active_flag = #{activeFlag},</if>
<if test="factoryCode != null">factory_code = #{factoryCode},</if>
<if test="sapFactoryCode != null">sap_factory_code = #{sapFactoryCode},</if>
</trim>
where raw_order_in_sn_id = #{rawOrderInSnId}
</update>
<delete id="deleteSparePartsInStorageByRawOrderInSnId" parameterType="String">
delete from wms_raw_order_in_sn where raw_order_in_sn_id = #{rawOrderInSnId}
</delete>
<delete id="deleteSparePartsInStorageByRawOrderInSnIds" parameterType="String">
delete from wms_raw_order_in_sn where raw_order_in_sn_id in
<foreach item="rawOrderInSnId" collection="array" open="(" separator="," close=")">
#{rawOrderInSnId}
</foreach>
</delete>
</mapper>
Loading…
Cancel
Save