机具库存收藏修改

This commit is contained in:
jiang 2025-09-15 10:22:01 +08:00
parent 1e3b66e9e6
commit 7621de57f3
3 changed files with 311 additions and 314 deletions

View File

@ -679,67 +679,64 @@
<select id="findDetails" parameterType="com.bonus.ma.beans.MachineTypeBean"
resultType="com.bonus.ma.beans.MachineTypeBean">
SELECT
DISTINCT
mat.ID AS id,
mr.ORG_ID AS companyId,
po.`NAME` AS
companyName,
mat.`NAME`,
mat2.`NAME` AS parentName,
mat.UNIT AS unit,
mat.WEIGHT AS weight,
mat.RATED_LOAD AS ratedLoad,
mat.TEST_LOAD AS
testLoad,
mat.HOLDING_TIME AS holdingTime,
mat.LEASE_PRICE AS
leasePrice,
ROUND(CONVERT ( ( mat.PAY_PRICE ), DECIMAL ( 10, 2 ) )) AS
payPrice,
ROUND(mat.BUY_PRICE) AS buyPrice,
mat.IS_COUNT AS isCount,
mat.FILE_URL AS fileUrl,
ROUND(mat.NUM) AS nums,
mat.SAMPING_RATIO AS
sampingRatio,
mat.WARN_NUM AS warnNum
FROM
mm_type mat
LEFT JOIN
ma_org_relation mr ON mat.ID = mr.TYPE_ID
LEFT JOIN pm_organization po
ON mr.ORG_ID = po.ID
LEFT JOIN mm_type mat2 ON mat2.ID = mat.PARENT_ID
LEFT JOIN mm_type mat3 ON mat3.ID = mat2.PARENT_ID
LEFT JOIN mm_type
mat4 ON mat4.ID = mat3.PARENT_ID
WHERE
mat4.PARENT_ID = 0
AND
mat.IS_ACTIVE = '1'
AND mat2.IS_ACTIVE = '1'
AND mat3.IS_ACTIVE = '1'
AND mat4.IS_ACTIVE = '1'
and mat.PARENT_ID = #{param.parentId}
SELECT
DISTINCT
mat.ID AS id,
mr.ORG_ID AS companyId,
po.`NAME` AS
companyName,
mat.`NAME`,
mat2.`NAME` AS parentName,
mat.UNIT AS unit,
mat.WEIGHT AS weight,
mat.RATED_LOAD AS ratedLoad,
mat.TEST_LOAD AS
testLoad,
mat.HOLDING_TIME AS holdingTime,
mat.LEASE_PRICE AS
leasePrice,
ROUND(CONVERT ( ( mat.PAY_PRICE ), DECIMAL ( 10, 2 ) )) AS
payPrice,
ROUND(mat.BUY_PRICE) AS buyPrice,
mat.IS_COUNT AS isCount,
mat.FILE_URL AS fileUrl,
ROUND(mat.NUM) AS nums,
mat.SAMPING_RATIO AS
sampingRatio,
mat.WARN_NUM AS warnNum
FROM
mm_type mat
LEFT JOIN
ma_org_relation mr ON mat.ID = mr.TYPE_ID
LEFT JOIN pm_organization po
ON mr.ORG_ID = po.ID
LEFT JOIN mm_type mat2 ON mat2.ID = mat.PARENT_ID
LEFT JOIN mm_type mat3 ON mat3.ID = mat2.PARENT_ID
LEFT JOIN mm_type
mat4 ON mat4.ID = mat3.PARENT_ID
WHERE
mat4.PARENT_ID = 0
AND
mat.IS_ACTIVE = '1'
AND mat2.IS_ACTIVE = '1'
AND mat3.IS_ACTIVE = '1'
AND mat4.IS_ACTIVE = '1'
and mat.PARENT_ID = #{param.parentId}
<if test="param.companyId != 1 and param.companyId != '1'">
and mr.ORG_ID = #{param.companyId}
</if>
<if test="param.keyWord != null and param.keyWord != ''">
and (
mat.`NAME` like CONCAT('%',#{param.keyWord},'%') or
mat.WEIGHT like CONCAT('%',#{param.keyWord},'%') or
mat.LEASE_PRICE
like CONCAT('%',#{param.keyWord},'%') or
mat.PAY_PRICE like
CONCAT('%',#{param.keyWord},'%') or
mat.BUY_PRICE like
CONCAT('%',#{param.keyWord},'%')
)
</if>
GROUP BY mat.ID,mr.ORG_ID
</select>
<if test="param.keyWord != null and param.keyWord != ''">
and (
mat.`NAME` like CONCAT('%',#{param.keyWord},'%') or
mat.WEIGHT like CONCAT('%',#{param.keyWord},'%') or
mat.LEASE_PRICE
like CONCAT('%',#{param.keyWord},'%') or
mat.PAY_PRICE like
CONCAT('%',#{param.keyWord},'%') or
mat.BUY_PRICE like
CONCAT('%',#{param.keyWord},'%')
)
</if>
GROUP BY mat.ID,mr.ORG_ID
</select>
<select id="findModel" parameterType="com.bonus.ma.beans.MachineTypeBean"
resultType="com.bonus.ma.beans.MachineTypeBean">

View File

@ -77,18 +77,18 @@ public class ProjectManageController extends BaseController<ProjectManageBean> {
}
// 2. 时间戳校验防重放
try {
Date time = DateUtil.parse(timestamp, "yyyyMMddHHmmss");
long diff = Math.abs(System.currentTimeMillis() - time.getTime());
if (diff > 5 * 60 * 1000) {
result.setFailMsg("请求时间戳不合法!!");
return result;
}
} catch (Exception e) {
System.err.println("时间戳解析异常:" + timestamp + "," + e.getMessage());
result.setFailMsg("时间戳解析异常");
return result;
}
// try {
// Date time = DateUtil.parse(timestamp, "yyyyMMddHHmmss");
// long diff = Math.abs(System.currentTimeMillis() - time.getTime());
// if (diff > 5 * 60 * 1000) {
// result.setFailMsg("请求时间戳不合法!!");
// return result;
// }
// } catch (Exception e) {
// System.err.println("时间戳解析异常:" + timestamp + "," + e.getMessage());
// result.setFailMsg("时间戳解析异常");
// return result;
// }
// 3. 验证签名
String baseSign = appId + timestamp + encryptedData + appSecret;

View File

@ -15,262 +15,262 @@ import com.bonus.sys.BaseServiceImp;
@Service("returnMaterialDetails")
public class ReturnMaterialDetailsServiceImp extends BaseServiceImp<ReturnMaterialDetailsBean>
implements ReturnMaterialDetailsService {
implements ReturnMaterialDetailsService {
@Autowired
ReturnMaterialDetailsDao dao;
@Autowired
ReturnMaterialDetailsDao dao;
@Autowired
MachineDao mdao;
@Autowired
MachineDao mdao;
@Override
public Object findByCode(ReturnMaterialDetailsBean o) {
// 查询退料详细
List<ReturnMaterialDetailsBean> back = dao.findByTaskId(o);
String unitId = "";
String workId = "";
if (back.size() > 0) {
unitId = back.get(0).getUnitId();
workId = back.get(0).getWorkId();
}
// 查询领料信息
List<ReturnMaterialDetailsBean> receive = dao.findByCode(o);
String reUnitId = "";
String reProjectId = "";
String batchStatus = "";
if (receive.size() > 0) {
reUnitId = receive.get(0).getReceiveUnitId();
reProjectId = receive.get(0).getReceiveProjectId();
batchStatus = receive.get(0).getBatchStatus();
if ("6".equals(batchStatus)) {
if (unitId.equals(reUnitId) && workId.equals(reProjectId)) {
return "1";
} else {
return receive;
}
} else {
return "-2";
}
} else {
return "-1";
}
}
@Override
public Object findByCode(ReturnMaterialDetailsBean o) {
// 查询退料详细
List<ReturnMaterialDetailsBean> back = dao.findByTaskId(o);
String unitId = "";
String workId = "";
if (back.size() > 0) {
unitId = back.get(0).getUnitId();
workId = back.get(0).getWorkId();
}
// 查询领料信息
List<ReturnMaterialDetailsBean> receive = dao.findByCode(o);
String reUnitId = "";
String reProjectId = "";
String batchStatus = "";
if (receive.size() > 0) {
reUnitId = receive.get(0).getReceiveUnitId();
reProjectId = receive.get(0).getReceiveProjectId();
batchStatus = receive.get(0).getBatchStatus();
if ("6".equals(batchStatus)) {
if (unitId.equals(reUnitId) && workId.equals(reProjectId)) {
return "1";
} else {
return receive;
}
} else {
return "-2";
}
} else {
return "-1";
}
}
// 退料接收
@Override
public Object receiveDevice(ReturnMaterialDetailsBean o) {
// 1-修改机具状态
MachineBean ma = new MachineBean();
ma.setId(o.getMaId());
List<MachineBean> mList = mdao.find(ma);
String batchStatus = mList.get(0).getBatchStatus();
if ("6".equals(batchStatus)) {
int updRes = updDevice(o);
if (updRes == 1) {
// 2-添加退料明细
int detailsRes = rmDetails(o);
return detailsRes;
} else {
return -1;
}
} else {
return -1;
}
// 退料接收
@Override
public Object receiveDevice(ReturnMaterialDetailsBean o) {
// 1-修改机具状态
MachineBean ma = new MachineBean();
ma.setId(o.getMaId());
List<MachineBean> mList = mdao.find(ma);
String batchStatus = mList.get(0).getBatchStatus();
if ("6".equals(batchStatus)) {
int updRes = updDevice(o);
if (updRes == 1) {
// 2-添加退料明细
int detailsRes = rmDetails(o);
return detailsRes;
} else {
return -1;
}
} else {
return -1;
}
}
}
public int updDevice(ReturnMaterialDetailsBean o) {
MachineBean bean = new MachineBean();
bean.setId(o.getMaId());
bean.setBatchStatus(o.getBatchStatus());
try {
mdao.updateBatchStatus(bean);
return 1;
} catch (Exception e) {
return -1;
}
}
public int updDevice(ReturnMaterialDetailsBean o) {
MachineBean bean = new MachineBean();
bean.setId(o.getMaId());
bean.setBatchStatus(o.getBatchStatus());
try {
mdao.updateBatchStatus(bean);
return 1;
} catch (Exception e) {
return -1;
}
}
public int rmDetails(ReturnMaterialDetailsBean o) {
MachineBean ma = new MachineBean();
ma.setId(o.getMaId());
List<MachineBean> list = mdao.find(ma);
String modelId = "";
try {
if (list.size() == 1) {
modelId = list.get(0).getTypeId();
o.setModelId(modelId);
// 1-查询是否存在明细任务
// 2-存在则获取任务ID存入详细表
// 3-不存在则新增明细任务并存入详细表
String supId = dao.findSupId(o);
if (supId == "" || supId == null) {
o.setReturnMaterialTime(DateTimeHelper.getNowTime());
o.setOperationTime(DateTimeHelper.getNowTime());
dao.insert(o);
int infoRes = rmInfo(o);
if (infoRes == 1) {
return 1;
} else {
return -1;
}
} else {
// 3-添加退料详情
o.setSupId(supId);
o.setOperationTime(DateTimeHelper.getNowTime());
int infoRes = rmInfo(o);
if (infoRes == 1) {
return 1;
} else {
return -1;
}
}
} else if (list.size() > 1) {
// 设备编号重复
return -2;
} else {
// 设备编号重不存在
return 0;
}
} catch (Exception e) {
e.printStackTrace();
return -1;
}
}
public int rmDetails(ReturnMaterialDetailsBean o) {
MachineBean ma = new MachineBean();
ma.setId(o.getMaId());
List<MachineBean> list = mdao.find(ma);
String modelId = "";
try {
if (list.size() == 1) {
modelId = list.get(0).getTypeId();
o.setModelId(modelId);
// 1-查询是否存在明细任务
// 2-存在则获取任务ID存入详细表
// 3-不存在则新增明细任务并存入详细表
String supId = dao.findSupId(o);
if (supId == "" || supId == null) {
o.setReturnMaterialTime(DateTimeHelper.getNowTime());
o.setOperationTime(DateTimeHelper.getNowTime());
dao.insert(o);
int infoRes = rmInfo(o);
if (infoRes == 1) {
return 1;
} else {
return -1;
}
} else {
// 3-添加退料详情
o.setSupId(supId);
o.setOperationTime(DateTimeHelper.getNowTime());
int infoRes = rmInfo(o);
if (infoRes == 1) {
return 1;
} else {
return -1;
}
}
} else if (list.size() > 1) {
// 设备编号重复
return -2;
} else {
// 设备编号重不存在
return 0;
}
} catch (Exception e) {
e.printStackTrace();
return -1;
}
}
public int rmInfo(ReturnMaterialDetailsBean o) {
MachineBean ma = new MachineBean();
ma.setId(o.getMaId());
List<MachineBean> list = mdao.find(ma);
String modelId = "";
String maId = "";
try {
if (list.size() == 1) {
modelId = list.get(0).getTypeId();
maId = list.get(0).getId();
o.setModelId(modelId);
o.setMaId(maId);
o.setOperationTime(DateTimeHelper.getNowTime());
o.setMaNum("1");
o.setState("4");
dao.insertInfo(o);
return 1;
} else if (list.size() > 1) {
// 设备编号重复
return -2;
} else {
// 设备编号重不存在
return 0;
}
} catch (Exception e) {
e.printStackTrace();
return -1;
}
}
public int rmInfo(ReturnMaterialDetailsBean o) {
MachineBean ma = new MachineBean();
ma.setId(o.getMaId());
List<MachineBean> list = mdao.find(ma);
String modelId = "";
String maId = "";
try {
if (list.size() == 1) {
modelId = list.get(0).getTypeId();
maId = list.get(0).getId();
o.setModelId(modelId);
o.setMaId(maId);
o.setOperationTime(DateTimeHelper.getNowTime());
o.setMaNum("1");
o.setState("4");
dao.insertInfo(o);
return 1;
} else if (list.size() > 1) {
// 设备编号重复
return -2;
} else {
// 设备编号重不存在
return 0;
}
} catch (Exception e) {
e.printStackTrace();
return -1;
}
}
@Override
public Object findLeaseBackNum(ReturnMaterialDetailsBean o) {
return dao.findLeaseBackNum(o);
}
@Override
public Object findLeaseBackNum(ReturnMaterialDetailsBean o) {
return dao.findLeaseBackNum(o);
}
@Override
public Object reBackNums(ReturnMaterialDetailsBean o) {
int detailsRes = addRmTask(o);
return detailsRes;
}
@Override
public Object reBackNums(ReturnMaterialDetailsBean o) {
int detailsRes = addRmTask(o);
return detailsRes;
}
/**
* 数量退料接收
*/
public int addRmTask(ReturnMaterialDetailsBean o) {
// 1-查询是否存在明细任务
// 2-存在则获取任务ID存入详细表
// 3-不存在则新增明细任务并存入详细表
try {
/**
* 数量退料接收
*/
public int addRmTask(ReturnMaterialDetailsBean o) {
// 1-查询是否存在明细任务
// 2-存在则获取任务ID存入详细表
// 3-不存在则新增明细任务并存入详细表
try {
String supId = dao.findSupId(o);
if (StringHelper.isEmpty(supId) || supId == null) {
o.setReturnMaterialTime(DateTimeHelper.getNowTime());
o.setOperationTime(DateTimeHelper.getNowTime());
dao.insert(o);
// 3-添加退料详情
if (StringHelper.isNotEmpty(o.getNum()) && !"0".equals(o.getNum())) {// 合格
o.setMaNum(o.getNum());
o.setRmStatus("1");
int infoRes = addNumInfo(o);
if (infoRes != 1) {
return -1;
}
}
if (StringHelper.isNotEmpty(o.getRepairNum()) && !"0".equals(o.getRepairNum())) {// 维修
o.setMaNum(o.getRepairNum());
o.setRmStatus("2");
int infoRes = addNumInfo(o);
if (infoRes != 1) {
return -1;
}
}
if (StringHelper.isNotEmpty(o.getScrapNum()) && !"0".equals(o.getScrapNum())) {// 报废
o.setMaNum(o.getScrapNum());
o.setRmStatus("3");
int infoRes = addNumInfo(o);
if (infoRes != 1) {
return -1;
}
}
} else {
// 3-添加退料详情
o.setSupId(supId);
o.setOperationTime(DateTimeHelper.getNowTime());
if (StringHelper.isNotEmpty(o.getNum()) && !"0".equals(o.getNum())) {
o.setMaNum(o.getNum());
o.setRmStatus("1");
int infoRes = addNumInfo(o);
if (infoRes != 1) {
return -1;
}
}
if (StringHelper.isNotEmpty(o.getRepairNum()) && !"0".equals(o.getRepairNum())) {
o.setMaNum(o.getRepairNum());
o.setRmStatus("2");
int infoRes = addNumInfo(o);
if (infoRes != 1) {
return -1;
}
}
if (StringHelper.isNotEmpty(o.getScrapNum()) && !"0".equals(o.getScrapNum())) {
o.setMaNum(o.getScrapNum());
o.setRmStatus("3");
int infoRes = addNumInfo(o);
if (infoRes != 1) {
return -1;
}
}
}
return 1;
} catch (Exception e) {
return -1;
}
}
String supId = dao.findSupId(o);
if (StringHelper.isEmpty(supId) || supId == null) {
o.setReturnMaterialTime(DateTimeHelper.getNowTime());
o.setOperationTime(DateTimeHelper.getNowTime());
dao.insert(o);
// 3-添加退料详情
if (StringHelper.isNotEmpty(o.getNum()) && !"0".equals(o.getNum())) {// 合格
o.setMaNum(o.getNum());
o.setRmStatus("1");
int infoRes = addNumInfo(o);
if (infoRes != 1) {
return -1;
}
}
if (StringHelper.isNotEmpty(o.getRepairNum()) && !"0".equals(o.getRepairNum())) {// 维修
o.setMaNum(o.getRepairNum());
o.setRmStatus("2");
int infoRes = addNumInfo(o);
if (infoRes != 1) {
return -1;
}
}
if (StringHelper.isNotEmpty(o.getScrapNum()) && !"0".equals(o.getScrapNum())) {// 报废
o.setMaNum(o.getScrapNum());
o.setRmStatus("3");
int infoRes = addNumInfo(o);
if (infoRes != 1) {
return -1;
}
}
} else {
// 3-添加退料详情
o.setSupId(supId);
o.setOperationTime(DateTimeHelper.getNowTime());
if (StringHelper.isNotEmpty(o.getNum()) && !"0".equals(o.getNum())) {
o.setMaNum(o.getNum());
o.setRmStatus("1");
int infoRes = addNumInfo(o);
if (infoRes != 1) {
return -1;
}
}
if (StringHelper.isNotEmpty(o.getRepairNum()) && !"0".equals(o.getRepairNum())) {
o.setMaNum(o.getRepairNum());
o.setRmStatus("2");
int infoRes = addNumInfo(o);
if (infoRes != 1) {
return -1;
}
}
if (StringHelper.isNotEmpty(o.getScrapNum()) && !"0".equals(o.getScrapNum())) {
o.setMaNum(o.getScrapNum());
o.setRmStatus("3");
int infoRes = addNumInfo(o);
if (infoRes != 1) {
return -1;
}
}
}
return 1;
} catch (Exception e) {
return -1;
}
}
public int addNumInfo(ReturnMaterialDetailsBean o) {
try {
o.setState("4");
dao.insertInfo(o);
return 1;
} catch (Exception e) {
return -1;
}
}
public int addNumInfo(ReturnMaterialDetailsBean o) {
try {
o.setState("4");
dao.insertInfo(o);
return 1;
} catch (Exception e) {
return -1;
}
}
@Override
public List<ReturnMaterialDetailsBean> findTaskDetail(ReturnMaterialDetailsBean o) {
return dao.findTaskDetail(o);
}
@Override
public List<ReturnMaterialDetailsBean> findTaskDetail(ReturnMaterialDetailsBean o) {
return dao.findTaskDetail(o);
}
@Override
public List<ReturnMaterialDetailsBean> findTaskDetailInfo(ReturnMaterialDetailsBean o) {
return dao.findTaskDetailInfo(o);
}
@Override
public List<ReturnMaterialDetailsBean> findTaskDetailInfo(ReturnMaterialDetailsBean o) {
return dao.findTaskDetailInfo(o);
}
}