|
|
@@ -0,0 +1,1442 @@
|
|
|
+package com.uas.eiswms.service.impl;
|
|
|
+
|
|
|
+
|
|
|
+import com.uas.eiswms.dao.BaseDao;
|
|
|
+import com.uas.eiswms.dao.ProdInOutDao;
|
|
|
+import com.uas.eiswms.model.SqlRowList;
|
|
|
+import com.uas.eiswms.service.ProdIOService;
|
|
|
+import com.uas.eiswms.service.SaleClashService;
|
|
|
+import com.uas.eiswms.util.*;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.jdbc.support.rowset.SqlRowSet;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import java.util.*;
|
|
|
+
|
|
|
+@Service
|
|
|
+public class ProdIOServiceImpl implements ProdIOService{
|
|
|
+
|
|
|
+ private Logger logger = LoggerFactory.getLogger(ProdIOServiceImpl.class);
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private BaseDao baseDao;
|
|
|
+ @Autowired
|
|
|
+ private SaleClashService saleClashService;
|
|
|
+ @Autowired
|
|
|
+ private ProdInOutDao prodInOutDao;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Map<String,Object> test(String pi_class, String lastUpdateTime, String condition, String master){
|
|
|
+ Map<String, Object> map = new HashMap<String, Object>();
|
|
|
+ map.put("success",true);
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Map<String, Object> getBill(String pi_class, String lastUpdateTime, String condition) {
|
|
|
+ Map<String, Object> map = new HashMap<String, Object>();
|
|
|
+ if (StringUtils.isEmpty(pi_class) || StringUtils.isEmpty(lastUpdateTime)) {
|
|
|
+ map.put("success", false);
|
|
|
+ map.put("msg", "单据类型或者参数为空");
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+ String caller = class2caller(pi_class);
|
|
|
+ String con= StringUtils.isEmpty(condition) ? "1=1" : condition.replaceAll("'", "''");
|
|
|
+ List<Object> mainFields = baseDao.getFieldDatasByCondition("form left join formdetail on fo_id=fd_foid", "fd_field",
|
|
|
+ "fo_caller='" + caller + "' and (upper(fd_field) like upper('pi_%') or upper(fd_field) like upper('prodinout%pi_%') ) order by fd_detno");
|
|
|
+ List<Object> detailFileds = baseDao.getFieldDatasByCondition("detailgrid", "dg_field", "dg_caller='"+ caller +"' and " +
|
|
|
+ "(upper(dg_field) like upper('pd_%') or upper(dg_field) like upper('prodiodetail.%pd_%')) order by DG_SEQUENCE");
|
|
|
+ if (mainFields != null && detailFileds != null) {
|
|
|
+ String mainStr = List2Str(mainFields);
|
|
|
+ String gridStr = List2Str(detailFileds);
|
|
|
+ List<Map<String, Object>> data = new ArrayList<Map<String, Object>>();
|
|
|
+ //获取主表信息
|
|
|
+ List<Map<String, Object>> list = baseDao.getJdbcTemplate().queryForList("select " + mainStr +
|
|
|
+ " from prodinout where pi_class=? and pi_lastupdatetime_user>to_date('"+ lastUpdateTime +"','yyyy-mm-dd') and " + con + " order by pi_id", pi_class);
|
|
|
+ List<Map<String, Object>> maps = BaseUtil.parseListDate(list);
|
|
|
+ if (maps != null) {
|
|
|
+ for (Map<String, Object> m : maps) {
|
|
|
+ Object pi_id = m.get("pi_id");
|
|
|
+ if (!StringUtils.isEmpty(pi_id)) {
|
|
|
+ //从表信息
|
|
|
+ List<Map<String, Object>> details = baseDao.getJdbcTemplate().queryForList("select " + gridStr + " from prodiodetail where pd_piid=?", pi_id);
|
|
|
+ m.put("detail", BaseUtil.parseListDate(details));
|
|
|
+ data.add(m);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ map.put("success", true);
|
|
|
+ map.put("data", data);
|
|
|
+ }
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String prePost(String data) {
|
|
|
+ List<Map<Object, Object>> maps = JsonUtil.toMapList(data);
|
|
|
+ if (maps.size() == 0) {
|
|
|
+ BaseUtil.showError("数据为空");
|
|
|
+ }
|
|
|
+ Object pi_id = maps.get(0).get("pi_id");
|
|
|
+ Object pi_class = maps.get(0).get("pi_class");
|
|
|
+ logger.info("过账前数据检测......");
|
|
|
+ String caller = class2caller(pi_class);
|
|
|
+ //检测传入数据字段是否存在,过账数量是否小于等于原数量
|
|
|
+ checkNecessaryFieldAndQty(caller, maps);
|
|
|
+ return post(Integer.valueOf(pi_id.toString()), caller);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void checkNecessaryFieldAndQty(String caller, List<Map<Object, Object>> maps) {
|
|
|
+ boolean in = baseDao.isProdIn(caller);
|
|
|
+ Double qty = 0.0;
|
|
|
+ List<String> sqls = new ArrayList<String>();
|
|
|
+ for (Map<Object,Object> m : maps) {
|
|
|
+ if (StringUtils.isEmpty(m.get("pi_id")) || StringUtils.isEmpty(m.get("pi_inoutno")) || StringUtils.isEmpty(m.get("pd_pdno"))) {
|
|
|
+ BaseUtil.showError("必填项未传入,行号:" + m.get("pd_pdno"));
|
|
|
+ }
|
|
|
+ Object pd_prodmadedate = m.get("pd_prodmadedate");//生产日期
|
|
|
+ Object pd_replydate = m.get("pd_replydate");//有效期
|
|
|
+ String qtyField = in ? "pd_inqty" : "pd_outqty";
|
|
|
+ qty = m.get(qtyField) == null ? 0.0 : Double.parseDouble(m.get(qtyField).toString());
|
|
|
+ Object realQty = baseDao.getFieldDataByCondition("prodiodetail", qtyField, "pd_piid=" + m.get("pi_id") +
|
|
|
+ "and pd_pdno=" + m.get("pd_pdno"));
|
|
|
+ if (realQty == null || (qty - Double.valueOf(realQty.toString()) > 0)) {
|
|
|
+ BaseUtil.showError("单据:" + m.get("pi_class") + " :" + m.get("pi_inoutno") + " 明细行:" + m.get("pd_pdno") + " 过账数量:" + qty + " 超出原明细数量:" + realQty);
|
|
|
+ }
|
|
|
+ if (in) {
|
|
|
+ if (pd_prodmadedate == null && pd_replydate == null) {
|
|
|
+ BaseUtil.showError("单据:" + m.get("pi_class") + " : " + m.get("pi_inoutno") + "生产日期与有效期不存在,禁止过账");
|
|
|
+ }
|
|
|
+ if (DateUtil.compareToday(pd_prodmadedate) || DateUtil.compareToday(pd_replydate)) {
|
|
|
+ BaseUtil.showError("单据:" + m.get("pi_inoutno") + "生产日期与有效期不能大于当天!");
|
|
|
+ }
|
|
|
+ sqls.add("update prodiodetail set " + qtyField + "=" + qty + ",pd_prodmadedate=" + (pd_prodmadedate == null ? "pd_prodmadedate" : "to_date('" + pd_prodmadedate + "','yyyy-mm-dd')") +
|
|
|
+ ",pd_replydate=" + (pd_replydate == null ? "pd_replydate" : "to_date('" + pd_replydate + "','yyyy-mm-dd')") +
|
|
|
+ " where pd_piid=" + m.get("pi_id") +" and pd_pdno=" + m.get("pd_pdno"));
|
|
|
+ } else {
|
|
|
+ sqls.add("update prodiodetail set " + qtyField + "=" + qty + " where pd_piid=" + m.get("pi_id") +" and pd_pdno=" + m.get("pd_pdno"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public String post(int pi_id, String caller) {
|
|
|
+ logger.info("过账初始化..............");
|
|
|
+ StringBuffer result = new StringBuffer();
|
|
|
+ try {
|
|
|
+ baseDao.execute("select pi_id from prodinout where pi_id=? for update", pi_id);
|
|
|
+ } catch (Exception e) {
|
|
|
+ System.out.println(e.getMessage());
|
|
|
+ BaseUtil.showError("当前单据有其他人正在操作");
|
|
|
+ }
|
|
|
+ baseDao.execute("update prodiodetail set pd_prodcode=upper(pd_prodcode) where nvl(pd_prodcode,' ')<>' ' and pd_piid="+pi_id);
|
|
|
+ // 只能对状态为[未过账]的单据进行过账操作!
|
|
|
+ Object[] status = baseDao.getFieldsDataByCondition("ProdInOut", new String[] { "pi_statuscode", "pi_invostatuscode", "pi_date",
|
|
|
+ "pi_class", "pi_recordman", "pi_inoutno" }, "pi_id=" + pi_id);
|
|
|
+ if (status[0].equals("POSTED")) {
|
|
|
+ BaseUtil.showError("只能对未过账的" + status[3] + "[" + status[5] + "]进行过账操作!");
|
|
|
+ }
|
|
|
+ //送货单号不一致不允许提交
|
|
|
+ if ("ProdInOut!PurcCheckin".equals(caller) || "ProdInOut!DefectIn".equals(caller)) {
|
|
|
+ if (baseDao.isDBSetting("VerifyApplyDetail!Deal", "turnByDeliver")) {
|
|
|
+ checkSendCode(pi_id);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 明细中如果有属于物料等级属于库存不可用的,就提示这些物料当前等级库存不可用
|
|
|
+ SqlRowSet rowList = baseDao.getJdbcTemplate()
|
|
|
+ .queryForRowSet(
|
|
|
+ "select wm_concat(pd_prodcode) prodcode from (select distinct pd_prodcode from prodiodetail "
|
|
|
+ + "left join product on pd_prodcode=pr_code left join productlevel on pr_level=pl_levcode where pd_piid=? and pl_id>0 "
|
|
|
+ + "and pl_isuseable=0 ) where rownum<=20", pi_id);
|
|
|
+ if (rowList.next()) {
|
|
|
+ if (rowList.getString("prodcode") != null) {
|
|
|
+ BaseUtil.showError("这些物料当前等级库存不可用,物料编号:" + rowList.getString("prodcode"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ baseDao.execute("update prodinout set (pi_whcode,pi_whname)=(select pd_whcode,pd_whname from prodiodetail where pd_piid=pi_id and nvl(pd_whcode,' ')<>' ' and rownum<2) where pi_id="
|
|
|
+ + pi_id + " and nvl(pi_whcode,' ')= ' '");
|
|
|
+ if (!status[1].equals("AUDITED")) {
|
|
|
+ BaseUtil.showError(status[3] + "[" + status[5] + "]未审核,不允许过账!");
|
|
|
+ }
|
|
|
+ String dets = baseDao
|
|
|
+ .getJdbcTemplate()
|
|
|
+ .queryForObject(
|
|
|
+ "select wm_concat(distinct pi_class||'['||pi_inoutno||']') from prodinout left join prodiodetail a on pi_id=pd_piid where exists (select 1 from prodiodetail B WHERE B.PD_IOID=A.PD_ID AND B.PD_PIID=?) AND Pi_STATUSCODE='UNPOST'",
|
|
|
+ String.class, pi_id);
|
|
|
+ if (dets != null) {
|
|
|
+ BaseUtil.showError("来源的" + dets + "未过账,本单据不允许过账!");
|
|
|
+ }
|
|
|
+ // 无来源订单不能直接过账
|
|
|
+ if (baseDao.isDBSetting(caller, "isWuPO")) {
|
|
|
+ int count = baseDao
|
|
|
+ .getCount("select count(*) from ProdIODetail where (pd_ordercode is null or pd_orderdetno is null) and pd_piid="
|
|
|
+ + pi_id);
|
|
|
+ if (!status[1].equals("AUDITED") && count != 0) {
|
|
|
+ BaseUtil.showError("无来源订单审核后才能过账");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ boolean isProdIn = baseDao.isProdIn(caller);
|
|
|
+ if (isProdIn) {
|
|
|
+ //检测入库单明细生产日期是否大于系统时间
|
|
|
+ inOverNow(caller, pi_id);
|
|
|
+ SqlRowSet rs = null;
|
|
|
+ // 入库类单据:如果pd_location为空,默认等于物料资料里的仓位pr_location
|
|
|
+ baseDao.execute(
|
|
|
+ "update prodiodetail set pd_location=(select pr_location from product where pr_code=pd_prodcode) where pd_piid=? and nvl(pd_location,' ')=' '",
|
|
|
+ pi_id);
|
|
|
+
|
|
|
+ rs = baseDao.getJdbcTemplate().queryForRowSet("SELECT pd_id FROM ProdioDetail where pd_piid=? and nvl(pd_batchcode,' ')=' '", pi_id);
|
|
|
+ while (rs.next()) {
|
|
|
+ baseDao.execute("update prodiodetail set pd_batchcode=? where pd_id=?", baseDao.getBatchcode(caller), rs.getInt("pd_id"));
|
|
|
+ }
|
|
|
+
|
|
|
+ // 入库单有生成条码但条码对应的物料或数量或批次号与明细行不一致则不允许过账
|
|
|
+ rs = baseDao.getJdbcTemplate()
|
|
|
+ .queryForRowSet(
|
|
|
+ "select wm_concat(pd_pdno)no,count(1)cn from prodiodetail left join (select sum(bi_inqty)inqty,bi_pdno,max(bi_prodcode)bi_prodcode,max(bi_batchcode)bi_batchcode from barcodeio"
|
|
|
+ + " where bi_piid=? group by bi_pdno) on bi_pdno=pd_pdno where pd_piid=? and pd_inqty>0 and inqty>0 "
|
|
|
+ + " and (nvl(inqty,0)<>pd_inqty or bi_prodcode<>pd_prodcode or bi_batchcode<>pd_batchcode) and rownum<30",
|
|
|
+ pi_id, pi_id);
|
|
|
+ if (rs.next() && rs.getInt("cn") > 0) {
|
|
|
+ BaseUtil.showError("条码与明细行中的物料或数量或批次号不一致,不允许过账,请先清除不一致条码!行号:" + rs.getString("no"));
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ SqlRowList rs = null;
|
|
|
+ rs = baseDao
|
|
|
+ .queryForRowSet(
|
|
|
+ "SELECT pd_id,ba_purcrate FROM ProdioDetail,batch where pd_batchid=ba_id and pd_piid=? and nvl(pd_batchid,0)<>0 and nvl(pd_outqty,0)>0",
|
|
|
+ pi_id);
|
|
|
+ while (rs.next()) {
|
|
|
+ if (rs.getGeneralDouble("ba_purcrate") != 0) {
|
|
|
+ baseDao.execute("update prodiodetail set pd_purcoutqty=round(nvl(pd_outqty,0)/" + rs.getGeneralDouble("ba_purcrate")
|
|
|
+ + ",8) where pd_id=" + rs.getObject("pd_id"));
|
|
|
+ } else {
|
|
|
+ baseDao.execute("update prodiodetail set pd_purcoutqty=nvl(pd_outqty,0) where pd_id=" + rs.getObject("pd_id"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ useDefaultTax(caller, pi_id);
|
|
|
+ allowZeroTax(caller, pi_id);
|
|
|
+ checkFreezeMonth(caller, status[2]);
|
|
|
+ checkCloseMonth(status[2]);
|
|
|
+ checkCommit(caller, pi_id);
|
|
|
+ checkBatch(caller, pi_id);
|
|
|
+ copcheck(pi_id, caller);
|
|
|
+ factorycheck(pi_id, caller);
|
|
|
+ //根据物料中的有效期天数更新有效期止
|
|
|
+ baseDao.getEndDate(caller, pi_id);
|
|
|
+ String res = null;
|
|
|
+ // 平台生成的销售订单转出货单过账必须等于销售订单明细序号和数量
|
|
|
+ if ("ProdInOut!Sale".equals(caller)) {
|
|
|
+ SqlRowList rs = baseDao
|
|
|
+ .queryForRowSet(
|
|
|
+ "select distinct sa_code,sum(pd_outqty) out_qty,pd_orderdetno from prodiodetail left join sale on sa_code=pd_ordercode where sa_ordertype='B2C' and nvl(sa_b2ccode,' ')<>' ' and pd_piid=? group by sa_code,pd_orderdetno",
|
|
|
+ pi_id);
|
|
|
+ while (rs.next()) {
|
|
|
+ rs = baseDao
|
|
|
+ .queryForRowSet(
|
|
|
+ "select distinct pd_ordercode pd_ordercode from prodiodetail where pd_piid=? and (pd_orderdetno not in (select sd_detno from saledetail where sd_code=?))"
|
|
|
+ + " OR "
|
|
|
+ + rs.getDouble("out_qty")
|
|
|
+ + " <>(select sd_qty from saledetail where sd_code=? and sd_detno=?) and pd_ordercode =?", pi_id,
|
|
|
+ rs.getString("sa_code"), rs.getString("sa_code"), rs.getString("pd_orderdetno"), rs.getString("sa_code"));
|
|
|
+ if (rs.next()) {
|
|
|
+ BaseUtil.showError("通过优软商城平台生成的发货单必须一次性发货,销售单号[" + rs.getString("pd_ordercode") + "]");
|
|
|
+ }
|
|
|
+ // 维护物流公司和物流单号
|
|
|
+ Object[] obs = baseDao.getFieldsDataByCondition("prodinout", new String[] { "pi_logisticscompany", "pi_logisticscode" },
|
|
|
+ "pi_id=" + pi_id);
|
|
|
+ if (obs[0] == null || obs[1] == null) {
|
|
|
+ BaseUtil.showError("请维护出货单的物流公司和物料单号信息!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if ("ProdInOut!PurcCheckin".equals(caller)) {// 采购验收单根据采购单号、序号,更新入库销售单号、序号
|
|
|
+ baseDao.execute(
|
|
|
+ "update prodiodetail set (pd_salecode,pd_saledetno,pd_topmothercode)=(select d.pd_salecode,d.pd_saledetno,d.pd_topmothercode from purchase left join purchasedetail d on pu_id=pd_puid where "
|
|
|
+ + " pd_ordercode=pu_code and pd_orderdetno=pd_detno) where pd_piid=?", pi_id);
|
|
|
+ }
|
|
|
+ // 调用过账存储过程前后都掉用一次gettotal方法,解决出入库单税率与发票不一致
|
|
|
+ getTotal(pi_id, caller);
|
|
|
+ // 执行过账操作
|
|
|
+ Object[] objs = baseDao.getFieldsDataByCondition("ProdInOut", new String[] { "pi_class", "pi_inoutno" }, "pi_id=" + pi_id);
|
|
|
+ baseDao.procedure("SP_GetCostPrice", new Object[] { objs[0].toString(), objs[1].toString() });
|
|
|
+ res = baseDao.callProcedure("Sp_SplitProdOut",
|
|
|
+ new Object[] { objs[0].toString(), objs[1].toString(), String.valueOf("wms") });
|
|
|
+
|
|
|
+ if (res != null && !res.trim().equals("")) {
|
|
|
+ // 重新添加提示限制信息
|
|
|
+ result.append(res + " " + objs[0].toString() + objs[1].toString() + ",过账失败");
|
|
|
+ return result.toString();
|
|
|
+ }
|
|
|
+ // @add 20170614 抓取批次号成功之后更新出库单据的备料状态
|
|
|
+ updatePdaStatus(caller, pi_id);
|
|
|
+ if (baseDao.isDBSetting(caller, "ifBatchCodeNotChange") && baseDao.isDBSetting(caller, "autoPostIn")) {
|
|
|
+ // 拨出单过帐后产生的拨入单批号不变,同一物料同仓库不能同时入两次相同的批号
|
|
|
+ SqlRowList rs1 = baseDao
|
|
|
+ .queryForRowSet("select count(1)n, wm_concat(pd_pdno)detno from (select pd_batchcode,pd_inwhcode,pd_prodcode,min(pd_pdno)pd_pdno,count(1)c from ProdIODetail where pd_piid="
|
|
|
+ + pi_id + " and pd_batchcode<>' ' group by pd_batchcode,pd_inwhcode,pd_prodcode ) where c> 1");
|
|
|
+ if (rs1.next()) {
|
|
|
+ if (rs1.getInt("n") > 0) {
|
|
|
+ BaseUtil.showError("拨出单过帐后产生的拨入单批号不变,同一物料同拨入仓库批号不能相同!行号:" + rs1.getString("detno"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ checkBatchRemain(pi_id);
|
|
|
+ // 存储过程
|
|
|
+ res = baseDao.callProcedure("Sp_CommitProdInout",
|
|
|
+ new Object[] { objs[0].toString(), objs[1].toString(), String.valueOf("wms") });
|
|
|
+ if (res != null && !res.trim().equals("")) {
|
|
|
+ BaseUtil.showError(res);
|
|
|
+ }
|
|
|
+ if (baseDao.isDBSetting("autoCreateApBill")) {
|
|
|
+ if ("采购验收单".equals(status[3]) || "采购验退单".equals(status[3]) || "委外验收单".equals(status[3]) || "委外验退单".equals(status[3])
|
|
|
+ || "用品验收单".equals(status[3]) || "用品验退单".equals(status[3])) {
|
|
|
+ dets = baseDao.getJdbcTemplate().queryForObject("select wm_concat(ab_code) from apbill where ab_source=? and ab_statuscode<>'POSTED'",
|
|
|
+ String.class, status[5]);
|
|
|
+ if (dets != null) {
|
|
|
+ BaseUtil.showError("发票" + dets + "未过账成功,请手工过账!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (baseDao.isDBSetting("autoCreateArBill")) {
|
|
|
+ if ("出货单".equals(status[3]) || "销售退货单".equals(status[3])) {
|
|
|
+ dets = baseDao.getJdbcTemplate().queryForObject(
|
|
|
+ "select wm_concat(ab_code) from arbill where AB_SOURCECODE=? and ab_statuscode<>'POSTED'", String.class,
|
|
|
+ status[5]);
|
|
|
+ if (dets != null) {
|
|
|
+ BaseUtil.showError("发票" + dets + "未过账成功,请手工过账!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ getTotal(pi_id, caller);
|
|
|
+ baseDao.updateByCondition("ProdInOut", "pi_statuscode='POSTED',pi_status='已过帐'," +
|
|
|
+ "pi_inoutman='wms',pi_date1=sysdate,pi_sendstatus='待上传'", "pi_id=" + pi_id);
|
|
|
+
|
|
|
+ }
|
|
|
+ // 出库类单据过账时,根据批号抓取batch.ba_vendorrate到prodiodetail.pd_vendorrate
|
|
|
+ if (!baseDao.isProdIn(caller)) {
|
|
|
+ baseDao.execute("update prodiodetail set pd_vendorrate=(select ba_vendorrate from batch where ba_code=pd_batchcode"
|
|
|
+ + " and ba_whcode =pd_whcode and ba_prodcode=pd_prodcode ) where pd_piid=" + pi_id + " and nvl(pd_vendorrate,0)=0");
|
|
|
+ }
|
|
|
+ logger.info("过账完成");
|
|
|
+ saleClashService.createSaleClash(pi_id, "ProdInOut");
|
|
|
+ if ("ProdInOut!AppropriationOut".equals(caller) || "ProdInOut!SaleAppropriationOut".equals(caller)) {
|
|
|
+ dets = null;
|
|
|
+ if (baseDao.isDBSetting(caller, "autoPostIn")) {
|
|
|
+ // 过账销售拨入单
|
|
|
+ dets = prodInOutDao.turnProdIO(pi_id);
|
|
|
+ logger.info("成功转拨出单,原单据id: " + pi_id);
|
|
|
+ //过账失败提醒
|
|
|
+ boolean showTurnProdIOError = baseDao.checkIf("ProdInOut",
|
|
|
+ "pi_class='拨入单' and pi_statuscode='UNPOST' and pi_inoutno=(select pi_relativeplace from ProdInOut where pi_class='拨出单' and pi_id="+pi_id+")");
|
|
|
+ if(showTurnProdIOError) {
|
|
|
+ result.append("您的拨出单:" + pi_id + "自动过账失败;");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (dets != null) {
|
|
|
+ result.append("拨入单明细行仓库对应的仓管员与当前过账人不一致,不允许进行当前操作!行号:" + dets + ";");
|
|
|
+ //BaseUtil.appendError("拨入单明细行仓库对应的仓管员与当前过账人不一致,不允许进行当前操作!行号:" + dets);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if ("ProdInOut!AppropriationOut".equals(caller)) {
|
|
|
+ SqlRowList rs3 = baseDao
|
|
|
+ .queryForRowSet(
|
|
|
+ "select b.pi_id pi_id,a.pi_relativeplace pi_relativeplace from prodinout a left join prodinout b on a.pi_relativeplace=b.pi_inoutno where a.pi_id=? and b.pi_class='拨入单'",
|
|
|
+ pi_id);
|
|
|
+ if (rs3.next()) {
|
|
|
+ /* BaseUtil.showErrorOnSuccess("拨出单过账成功!系统产生的拨入单号:<a href=\"javascript:openUrl('jsps/scm/reserve/prodInOut.jsp?formCondition=pi_idIS"
|
|
|
+ + rs3.getInt("pi_id")
|
|
|
+ + "&gridCondition=pd_piidIS"
|
|
|
+ + rs3.getInt("pi_id")
|
|
|
+ + "&whoami=ProdInOut!AppropriationIn')\">"
|
|
|
+ + rs3.getString("pi_relativeplace") + "</a> ");*/
|
|
|
+ result.append("拨出单过账成功!系统产生的拨入单号:" + rs3.getString("pi_relativeplace"));
|
|
|
+ return result.toString();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if ("ProdInOut!PurcCheckin".equals(caller)) {// 采购验收单过账根据采购单+采购单序号更新pd_vendorrate
|
|
|
+ // ba_vendorrate
|
|
|
+ SqlRowList pdRowList = baseDao
|
|
|
+ .queryForRowSet("select pd_id,nvl(pd_batchid,0) pd_batchid,nvl(pd_ordercode,' ') pd_ordercode,nvl(pd_orderdetno,0) pd_orderdetno from prodiodetail where pd_piid="
|
|
|
+ + pi_id);
|
|
|
+ while (pdRowList.next()) {
|
|
|
+ baseDao.execute("update prodiodetail set pd_vendorrate=(select pd_vendorrate from purchasedetail where pd_code='"
|
|
|
+ + pdRowList.getObject("pd_ordercode") + "' and pd_detno='" + pdRowList.getObject("pd_orderdetno")
|
|
|
+ + "') where pd_id=" + pdRowList.getObject("pd_id"));
|
|
|
+ baseDao.execute("update batch set ba_vendorrate=(select pd_vendorrate from purchasedetail where pd_code='"
|
|
|
+ + pdRowList.getObject("pd_ordercode") + "' and pd_detno='" + pdRowList.getObject("pd_orderdetno")
|
|
|
+ + "') where ba_id=" + pdRowList.getObject("pd_batchid"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 2017-08-30 重新根据pdno更新批号仓库属性
|
|
|
+ if (isProdIn) {
|
|
|
+ baseDao.execute(
|
|
|
+ "update barcodeio set (bi_batchcode,bi_batchid,bi_whcode)=(select pd_batchcode,pd_batchid,pd_whcode from prodiodetail where bi_piid=pd_piid and pd_pdno=bi_pdno) where bi_piid=? and nvl(bi_status,0)=0",
|
|
|
+ pi_id);
|
|
|
+ baseDao.execute(
|
|
|
+ "update batch set ba_hasbarcode=-1 where ba_id in (select pd_batchid from prodiodetail "
|
|
|
+ + " where pd_piid=?) and NVL(ba_hasbarcode,0)=0 and ba_id in (select bi_batchid from barcodeio where bi_inqty>0 and bi_status=0) ",
|
|
|
+ pi_id);
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * @author wsy
|
|
|
+ * 其它入库单:如果选择了采购单号、采购序号后,提交、审核的时候要判断采购单号+采购序号+物料编号是否一致,不一致限制提交
|
|
|
+ * 、审核
|
|
|
+ */
|
|
|
+ if ("ProdInOut!OtherIn".equals(caller)) {
|
|
|
+ baseDao.execute("update purchasedetail set pd_beipinacceptqty=(nvl((select sum(nvl(pd_purcinqty,0)) from prodiodetail where pd_piclass='其它入库单' and pd_ordercode=pd_code and pd_orderdetno=pd_detno and pd_status=99),0))where (pd_code,pd_detno) in (select pd_ordercode,pd_orderdetno from prodiodetail where pd_piid="
|
|
|
+ + pi_id + " and pd_piclass='其它入库单')");
|
|
|
+ }
|
|
|
+ return result.toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void checkBatchRemain(Object pi_id) {
|
|
|
+ int count = baseDao.getCount("select count(1) from documentsetup where ds_name=(select pi_class from prodinout " + "where pi_id="
|
|
|
+ + pi_id + ") and (ds_inorout = '-IN' or ds_inorout = 'OUT')");
|
|
|
+ if (count > 0) {
|
|
|
+ String pdnos1 = baseDao.getJdbcTemplate().queryForObject(
|
|
|
+ "select WMSYS.WM_CONCAT(pd_pdno) from (select pd_pdno from prodiodetail left join batch on"
|
|
|
+ + " pd_batchcode=ba_code and ba_whcode = pd_whcode and ba_prodcode = pd_prodcode "
|
|
|
+ + "where pd_piid=? and ba_code is null order by pd_pdno) where rownum<20", String.class, pi_id);
|
|
|
+ String pdnos2 = baseDao
|
|
|
+ .getJdbcTemplate()
|
|
|
+ .queryForObject(
|
|
|
+ "select WMSYS.WM_CONCAT(pd_pdno) from (select WMSYS.WM_CONCAT(pd_pdno) pd_pdno,max(pd_batchcode),"
|
|
|
+ + "sum(pd_outqty),max(ba_remain),max(ba_code) from prodiodetail left join batch on pd_batchcode=ba_code and "
|
|
|
+ + "ba_whcode = pd_whcode and ba_prodcode = pd_prodcode where pd_piid=? group by pd_batchcode,pd_prodcode,pd_whcode"
|
|
|
+ + " having sum(pd_outqty)>max(ba_remain) ) where rownum<20", String.class, pi_id);
|
|
|
+ if (pdnos1 != null || pdnos2 != null) {
|
|
|
+ String error1 = pdnos1 == null ? "" : "找不到您所指的批号,请修改批号或点击【重置批号】再过账!行号是:" + pdnos1 + "<br>";
|
|
|
+ String error2 = pdnos2 == null ? "" : "批号的库存数小于出库数量,请修改批号或点击【重置批号】再过账!行号是:" + pdnos2 + "<br>";
|
|
|
+ BaseUtil.showError(error1 + error2);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void getTotal(Object pi_id, String caller) {
|
|
|
+ baseDao.execute("update prodiodetail set pd_purcinqty=nvl(pd_inqty,0) where pd_piid=" + pi_id
|
|
|
+ + " and exists (select 1 from product where pd_prodcode=pr_code and nvl(pr_purcunit,pr_unit)=pr_unit) ");
|
|
|
+ baseDao.execute("update prodiodetail set pd_purcoutqty=nvl(pd_outqty,0) where pd_piid=" + pi_id
|
|
|
+ + " and exists (select 1 from product where pd_prodcode=pr_code and nvl(pr_purcunit,pr_unit)=pr_unit)");
|
|
|
+
|
|
|
+ baseDao.execute("update prodiodetail set pd_purcinqty=pd_inqty/(select case when nvl(pr_purcrate,0)<>0 then pr_purcrate else 1 end from product where pr_code=pd_prodcode) where pd_piid="
|
|
|
+ + pi_id + " and nvl(pd_purcinqty,0)=0");
|
|
|
+
|
|
|
+ if ("ProdInOut!PurcCheckin".equals(caller) || "ProdInOut!PurcCheckout".equals(caller)) {
|
|
|
+ // 采购
|
|
|
+ baseDao.updateByCondition("ProdIODetail",
|
|
|
+ "pd_orderprice=nvl((select pd_price from PurchaseDetail where pd_code=pd_ordercode and pd_pdno=pd_orderdetno),0)",
|
|
|
+ "pd_piid=" + pi_id + " and nvl(pd_orderprice,0)=0");
|
|
|
+ // 强制取采购单明细表中的对应的税率
|
|
|
+ baseDao.execute(
|
|
|
+ "update ProdIODetail set pd_taxrate=(select nvl(pd_rate,0) from PurchaseDetail where pd_code=pd_ordercode and pd_pdno=pd_orderdetno) where pd_ordercode is not null and pd_piid=?",
|
|
|
+ pi_id);
|
|
|
+ baseDao.execute("update ProdIODetail set pd_ordertotal=round(pd_orderprice*(case when nvl(pd_purcinqty,0)+nvl(pd_purcoutqty,0)=0 then nvl(pd_inqty,0)+nvl(pd_outqty,0) else nvl(pd_purcinqty,0)+nvl(pd_purcoutqty,0) end),2) where pd_piid="
|
|
|
+ + pi_id);
|
|
|
+ baseDao.execute("update ProdIODetail set pd_taxtotal=round(pd_orderprice*(case when nvl(pd_purcinqty,0)+nvl(pd_purcoutqty,0)=0 then nvl(pd_inqty,0)+nvl(pd_outqty,0) else nvl(pd_purcinqty,0)+nvl(pd_purcoutqty,0) end)*nvl(pd_taxrate,0)/(100+nvl(pd_taxrate,0)),2),pd_nettotal=round(pd_orderprice*(case when nvl(pd_purcinqty,0)+nvl(pd_purcoutqty,0)=0 then nvl(pd_inqty,0)+nvl(pd_outqty,0) else nvl(pd_purcinqty,0)+nvl(pd_purcoutqty,0) end)/(1+nvl(pd_taxrate,0)/100),2) where pd_piid="
|
|
|
+ + pi_id);
|
|
|
+ baseDao.updateByCondition("ProdIODetail", " pd_total=round(nvl(pd_price,0)*(nvl(pd_inqty,0)+nvl(pd_outqty,0)),2)", "pd_piid="
|
|
|
+ + pi_id);
|
|
|
+ baseDao.updateByCondition("ProdInOut",
|
|
|
+ "pi_total = round(nvl((SELECT sum(round(pd_ordertotal,2)) FROM ProdIODetail WHERE pd_piid=pi_id),0),2)", "pi_id="
|
|
|
+ + pi_id);
|
|
|
+ baseDao.updateByCondition("ProdInOut", "pi_totalupper=L2U(nvl(pi_total,0))", "pi_id=" + pi_id);
|
|
|
+ } else if ("ProdInOut!Sale".equals(caller) || "ProdInOut!SaleReturn".equals(caller)) {
|
|
|
+ baseDao.updateByCondition(
|
|
|
+ "ProdIODetail",
|
|
|
+ "pd_ordertotal=round(nvl(pd_sendprice,0)*(case when nvl(pd_purcinqty,0)+nvl(pd_purcoutqty,0)=0 then nvl(pd_inqty,0)+nvl(pd_outqty,0) else nvl(pd_purcinqty,0)+nvl(pd_purcoutqty,0) end),2),pd_total=round(nvl(pd_price,0)*(nvl(pd_inqty,0)+nvl(pd_outqty,0)),2)",
|
|
|
+ "pd_piid=" + pi_id);
|
|
|
+ baseDao.updateByCondition(
|
|
|
+ "ProdIODetail",
|
|
|
+ "pd_netprice=round(pd_sendprice/(1+pd_taxrate/100),8),pd_nettotal=round(pd_sendprice*(case when nvl(pd_purcinqty,0)+nvl(pd_purcoutqty,0)=0 then nvl(pd_inqty,0)+nvl(pd_outqty,0) else nvl(pd_purcinqty,0)+nvl(pd_purcoutqty,0) end)/(1+nvl(pd_taxrate,0)/100),2)",
|
|
|
+ "pd_piid=" + pi_id);
|
|
|
+ baseDao.updateByCondition("ProdInOut",
|
|
|
+ "pi_total=round(nvl((SELECT sum(round(pd_ordertotal,2)) FROM ProdIODetail WHERE pd_piid=pi_id),0),2)", "pi_id=" + pi_id);
|
|
|
+ baseDao.execute("update prodiodetail set pd_customprice=pd_sendprice, pd_taxamount=pd_ordertotal "
|
|
|
+ + "where pd_piclass in ('出货单','销售退货单') and pd_piid=? and nvl(pd_customprice,0)=0", pi_id);
|
|
|
+ baseDao.updateByCondition("ProdInOut", "pi_totalupper=L2U(nvl(pi_total,0))", "pi_id=" + pi_id);
|
|
|
+ // 成品标准成本,用于报价毛利润统计
|
|
|
+ baseDao.execute("UPDATE product set pr_cost=nvl((select price from ( select qd_prodcode,round(qd_factprice*qu_rate,2) price,"
|
|
|
+ + " row_number() over(partition by qd_prodcode order by qu_auditdate desc) rn from quotation,quotationdetail "
|
|
|
+ + "where qu_id=qd_quid and qu_statuscode='AUDITED') t1 where rn=1 and qd_prodcode=pr_code),0) "
|
|
|
+ + "where nvl(pr_cost,0)=0 and pr_code in (select pd_prodcode from prodiodetail where pd_piid=?)", pi_id);
|
|
|
+ baseDao.execute("UPDATE prodiodetail SET pd_showprice=nvl((select pr_cost from product where pd_prodcode=pr_code),0)"
|
|
|
+ + "WHERE pd_piid=?", pi_id);
|
|
|
+ } else {
|
|
|
+ baseDao.updateByCondition("ProdIODetail", "pd_total=round(nvl(pd_price,0)*(nvl(pd_inqty,0)+nvl(pd_outqty,0)),2)", "pd_piid="
|
|
|
+ + pi_id);
|
|
|
+ baseDao.updateByCondition(
|
|
|
+ "ProdInOut",
|
|
|
+ "pi_total=(SELECT sum(round(nvl(pd_price,0)*(nvl(pd_inqty,0)+nvl(pd_outqty,0)),2)) FROM ProdIODetail WHERE pd_piid=pi_id)",
|
|
|
+ "pi_id=" + pi_id);
|
|
|
+ baseDao.updateByCondition("ProdInOut", "pi_totalupper=L2U(nvl(pi_total,0))", "pi_id=" + pi_id);
|
|
|
+ }
|
|
|
+ if ("ProdInOut!Sale".equals(caller) || "ProdInOut!SaleReturn".equals(caller) || "ProdInOut!AppropriationOut".equals(caller)
|
|
|
+ || "ProdInOut!OtherOut".equals(caller) || "ProdInOut!ExchangeOut".equals(caller)) {
|
|
|
+ Object cardcode = baseDao.getFieldDataByCondition("ProdInOut", "pi_cardcode", "pi_id=" + pi_id);
|
|
|
+ baseDao.execute("update prodiodetail set (PD_CUSTPRODCODE,PD_CUSTPRODSPEC,pd_custproddetail)=(select max(pc_custprodcode),max(pc_custprodspec),max(pc_custproddetail) from ProductCustomer left join Product on pc_prodid=pr_id left join customer on pc_custid=cu_id where cu_code='"
|
|
|
+ + cardcode
|
|
|
+ + "' and pd_prodcode=pr_code) where pd_piid="
|
|
|
+ + pi_id
|
|
|
+ + " and nvl(pd_custprodcode,' ')=' ' and nvl(pd_custprodspec,' ')=' ' and pd_piclass in ('销售退货单', '出货单', '其它出库单', '拨出单', '换货出库单')");
|
|
|
+ }
|
|
|
+ // 入库类单据:如果pd_location为空,默认等于物料资料里的仓位pr_location
|
|
|
+ if (baseDao.isProdIn(caller)) {
|
|
|
+ baseDao.execute(
|
|
|
+ "update prodiodetail set pd_location=(select pr_location from product where pr_code=pd_prodcode) where pd_piid=? and nvl(pd_location,' ')=' '",
|
|
|
+ pi_id);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private String class2caller(Object pi_class) {
|
|
|
+ if(StringUtils.isEmpty(pi_class)) {
|
|
|
+ BaseUtil.showError("单据类型为空,请指定真确的单据类型!");
|
|
|
+ }
|
|
|
+ switch (pi_class.toString()) {
|
|
|
+ case "出货单":
|
|
|
+ return "ProdInOut!Sale";
|
|
|
+ case "采购验收单":
|
|
|
+ return "ProdInOut!PurcCheckin";
|
|
|
+ case "采购验退单":
|
|
|
+ return "ProdInOut!PurcCheckout";
|
|
|
+ case "销售退货单":
|
|
|
+ return "ProdInOut!SaleReturn";
|
|
|
+ case "拨出单":
|
|
|
+ return "ProdInOut!AppropriationOut";
|
|
|
+ case "其它入库单":
|
|
|
+ return "ProdInOut!OtherIn";
|
|
|
+ case "其它出库单":
|
|
|
+ return "ProdInOut!OtherOut";
|
|
|
+ case "其它采购出库单":
|
|
|
+ return "ProdInOut!OtherPurcOut";
|
|
|
+ case "其它采购入库单":
|
|
|
+ return "ProdInOut!OtherPurcIn";
|
|
|
+ default:
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void copcheck(Object pi_id, String caller) {
|
|
|
+ if (baseDao.isDBSetting("CopCheck")) {
|
|
|
+ // 出入库单:明细行采购单所属公司与当前单所属公司必须一致,可在提交、打印、审核、过账等操作前配置
|
|
|
+ String dets = baseDao
|
|
|
+ .getJdbcTemplate()
|
|
|
+ .queryForObject(
|
|
|
+ "select wm_concat(pd_pdno) from ProdIODetail left join ProdInOut on pd_piid=pi_id left join Purchase on pd_ordercode=pu_code where pi_id=? and nvl(pu_cop,' ')<>nvl(pi_cop,' ') and nvl(pd_ordercode,' ')<>' ' "
|
|
|
+ + " and pd_piclass in ('采购验收单','采购验退单')", String.class, pi_id);
|
|
|
+ if (dets != null) {
|
|
|
+ BaseUtil.showError("明细行采购单所属公司与当前单所属公司不一致,不允许进行当前操作!行号:" + dets);
|
|
|
+ }
|
|
|
+ // 出入库单:明细行销售单所属公司与当前单所属公司必须一致,可在提交、打印、审核、过账等操作前配置
|
|
|
+ dets = baseDao
|
|
|
+ .getJdbcTemplate()
|
|
|
+ .queryForObject(
|
|
|
+ "select wm_concat(pd_pdno) from ProdIODetail left join ProdInOut on pd_piid=pi_id left join Sale on pd_ordercode=sa_code where pi_id=? and nvl(sa_cop,' ')<>nvl(pi_cop,' ') and nvl(pd_ordercode,' ')<>' ' "
|
|
|
+ + "and pd_piclass in ('出货单','销售退货单','销售拨出单','销售拨入单')", String.class, pi_id);
|
|
|
+ if (dets != null) {
|
|
|
+ BaseUtil.showError("明细行销售单所属公司与当前单所属公司不一致,不允许进行当前操作!行号:" + dets);
|
|
|
+ }
|
|
|
+ // 出货单:来源单所属公司与当前单所属公司不一致,不允许进行当前操作
|
|
|
+ dets = baseDao
|
|
|
+ .getJdbcTemplate()
|
|
|
+ .queryForObject(
|
|
|
+ "select wm_concat(pd_pdno) from ProdIODetail left join ProdInOut on pd_piid=pi_id left join Sendnotify on pd_snid=sn_id where pi_id=? and nvl(sn_cop,' ')<>nvl(pi_cop,' ') and nvl(pd_snid,0)<>0 ",
|
|
|
+ String.class, pi_id);
|
|
|
+ if (dets != null) {
|
|
|
+ BaseUtil.showError("明细来源通知单所属公司与当前单所属公司不一致,不允许进行当前操作!行号:" + dets);
|
|
|
+ }
|
|
|
+ // 出入库单:明细行制造单所属公司与当前单所属公司必须一致,可在提交、打印、审核、过账等操作前配置
|
|
|
+ dets = baseDao
|
|
|
+ .getJdbcTemplate()
|
|
|
+ .queryForObject(
|
|
|
+ "select wm_concat(pd_pdno) from ProdIODetail left join ProdInOut on pd_piid=pi_id left join Make on pd_ordercode=ma_code where pi_id=? and nvl(ma_cop,' ')<>nvl(pi_cop,' ') and nvl(pd_ordercode,' ')<>' ' "
|
|
|
+ + "and pd_piclass in ('生产领料单','生产退料单','生产补料单','完工入库单','拆件入库单')", String.class, pi_id);
|
|
|
+ if (dets != null) {
|
|
|
+ BaseUtil.showError("明细行制造单所属公司与当前单所属公司不一致,不允许进行当前操作!行号:" + dets);
|
|
|
+ }
|
|
|
+ // 出入库单:明细行委外单所属公司与当前单所属公司必须一致,可在提交、打印、审核、过账等操作前配置
|
|
|
+ dets = baseDao
|
|
|
+ .getJdbcTemplate()
|
|
|
+ .queryForObject(
|
|
|
+ "select wm_concat(pd_pdno) from ProdIODetail left join ProdInOut on pd_piid=pi_id left join Make on pd_ordercode=ma_code where pi_id=? and nvl(ma_cop,' ')<>nvl(pi_cop,' ') and nvl(pd_ordercode,' ')<>' ' "
|
|
|
+ + "and pd_piclass in ('委外验收单','委外验退单','委外领料单','委外退料单','委外补料单')", String.class, pi_id);
|
|
|
+ if (dets != null) {
|
|
|
+ BaseUtil.showError("明细行委外单所属公司与当前单所属公司不一致,不允许进行当前操作!行号:" + dets);
|
|
|
+ }
|
|
|
+ if ("ProdInOut!SaleAppropriationOut".equals(caller) || "ProdInOut!OtherOut".equals(caller)
|
|
|
+ || "ProdInOut!AppropriationOut".equals(caller)) {
|
|
|
+ dets = baseDao
|
|
|
+ .getJdbcTemplate()
|
|
|
+ .queryForObject(
|
|
|
+ "select wm_concat(pd_pdno) from ProdIODetail left join ProdInOut on pd_piid=pi_id left join SaleForecast on pd_plancode=sf_code where pi_id=? and nvl(sf_cop,' ')<>nvl(pi_cop,' ') and nvl(pd_plancode,' ')<>' ' "
|
|
|
+ + "and pd_piclass in ('销售拨出单','其它出库单')", String.class, pi_id);
|
|
|
+ if (dets != null) {
|
|
|
+ BaseUtil.showError("明细行销售预测单所属公司与当前单所属公司不一致,不允许进行当前操作!行号:" + dets);
|
|
|
+ }
|
|
|
+ dets = baseDao
|
|
|
+ .getJdbcTemplate()
|
|
|
+ .queryForObject(
|
|
|
+ "select wm_concat(pd_pdno) from ProdIODetail left join prodinout on pd_piid=pi_id left join Warehouse on pd_inwhcode=wh_code where pi_id=? and pi_class in ('销售拨出单','拨出单') and nvl(pi_cop,' ')<>nvl(wh_cop,' ')",
|
|
|
+ String.class, pi_id);
|
|
|
+ if (dets != null) {
|
|
|
+ BaseUtil.showError("单据所属公司和明细行拨入仓库的所属公司不一致,不允许进行当前操作!行号:" + dets);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 出入库单限制界面的所属公司和仓库的所属公司必须一致,可在提交、打印、审核、过账等操作前配置
|
|
|
+ dets = baseDao
|
|
|
+ .getJdbcTemplate()
|
|
|
+ .queryForObject(
|
|
|
+ "select wm_concat(pd_pdno) from ProdIODetail left join prodinout on pd_piid=pi_id left join Warehouse on pd_whcode=wh_code where nvl(pi_cop,' ')<>nvl(wh_cop,' ') and pi_id=? and pi_class not in ('成本调整单')",
|
|
|
+ String.class, pi_id);
|
|
|
+ if (dets != null) {
|
|
|
+ BaseUtil.showError("单据所属公司和明细行仓库的所属公司不一致,不允许进行当前操作!行号:" + dets);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void checkBatch(String caller, Object pi_id) {
|
|
|
+ if (baseDao.isProdIn(caller)) {
|
|
|
+ // 入库单据,同一物料同仓库不能同时入两次相同的批号
|
|
|
+ SqlRowList rs = baseDao
|
|
|
+ .queryForRowSet("select count(1)n, wm_concat(pd_piclass||'['||pd_inoutno||']行号['||pd_pdno||']')detno from (select pd_batchcode,pd_whcode,pd_prodcode,min(pd_pdno)pd_pdno,min(pd_inoutno)pd_inoutno,min(pd_piclass)pd_piclass,count(1)c from ProdIODetail where pd_piid="
|
|
|
+ + pi_id + " and pd_batchcode<>' ' group by pd_batchcode,pd_whcode,pd_prodcode ) where c> 1");
|
|
|
+ if (rs.next()) {
|
|
|
+ if (rs.getInt("n") > 0) {
|
|
|
+ BaseUtil.showError("同一物料同仓库不能同时入两次相同的批号!" + rs.getString("detno"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ rs = baseDao
|
|
|
+ .queryForRowSet("select count(1) n,wm_concat(pd_piclass||'['||pd_inoutno||']行号['||pd_pdno||']')detno "
|
|
|
+ + "from (select pd_piclass,pd_inoutno,pd_pdno from ProdIODetail where pd_piid="
|
|
|
+ + pi_id
|
|
|
+ + " and pd_batchcode is not null and exists (select 1 from batch where ba_code=pd_batchcode and ba_prodcode=pd_prodcode "
|
|
|
+ + "and ba_whcode=pd_whcode and (nvl(ba_remain,0)<>0 or nvl(ba_inqty,0)<>0))) where rownum<30");
|
|
|
+ if (rs.next()) {
|
|
|
+ if (rs.getInt("n") > 0) {
|
|
|
+ BaseUtil.showError("批号已存在,不能重复入库!" + rs.getString("detno"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void checkCommit(String caller, Object pi_id) {
|
|
|
+
|
|
|
+ if (!caller.equals("ProdInOut!AppropriationOut") && !caller.equals("ProdInOut!AppropriationIn")) {
|
|
|
+ baseDao.execute("update prodiodetail set pd_whcode=(select pi_whcode from prodinout where pd_piid=pi_id) where pd_piid="
|
|
|
+ + pi_id + " and NVL(pd_whcode,' ')=' '");
|
|
|
+ }
|
|
|
+ if (caller.equals("ProdInOut!Make!Return") || caller.equals("ProdInOut!OutsideReturn")) {
|
|
|
+ baseDao.execute("update prodiodetail a set pd_prodmadedate=(select min(ba_date) from prodiodetail b left join batch on b.pd_batchid=ba_id where a.pd_ordercode=b.pd_ordercode and a.pd_prodcode=b.pd_prodcode and nvl(b.pd_batchcode,' ')<>' ' and ((b.pd_piclass ='生产领料单' and a.pd_piclass='生产退料单') or (b.pd_piclass ='委外领料单' and a.pd_piclass='委外退料单'))) where pd_piid="
|
|
|
+ + pi_id + " and pd_prodmadedate is null");
|
|
|
+ } else {
|
|
|
+ baseDao.execute("update prodiodetail set pd_prodmadedate=(select pi_date from prodinout where pd_piid=pi_id) where pd_piid="
|
|
|
+ + pi_id + " and pd_prodmadedate is null");
|
|
|
+ }
|
|
|
+ if ("ProdInOut!CostChange".equals(caller)) {
|
|
|
+ baseDao.execute(
|
|
|
+ "update prodiodetail set (pd_orderqty,pd_orderprice)=(select ba_remain,ba_price from batch where ba_code=pd_batchcode and pd_prodcode=ba_prodcode and ba_whcode=pd_whcode) where pd_piid=?",
|
|
|
+ pi_id);
|
|
|
+ baseDao.execute(
|
|
|
+ "update prodiodetail set pd_total=round(nvl(pd_orderqty,0)*(nvl(pd_price,0)-nvl(pd_orderprice,0)),2) where pd_piid=?",
|
|
|
+ pi_id);
|
|
|
+ }
|
|
|
+ baseDao.execute("update prodiodetail set pd_qctype=(select ve_class from qua_verifyapplydetail left join qua_verifyapplydetaildet on ved_veid=ve_id where pd_qcid=ved_id) where pd_piid="
|
|
|
+ + pi_id + " and nvl(pd_qcid,0)<>0");
|
|
|
+ String dets = baseDao
|
|
|
+ .getJdbcTemplate()
|
|
|
+ .queryForObject(
|
|
|
+ "select wm_concat(pd_piclass||'['||pd_inoutno||']行号['||pd_pdno||']') from ProdIODetail left join product on pr_code=pd_prodcode where pd_piid=? and NVL(pr_statuscode,' ')<>'AUDITED'",
|
|
|
+ String.class, pi_id);
|
|
|
+ if (dets != null) {
|
|
|
+ BaseUtil.showError("明细行物料不存在或者状态不等于已审核,不允许进行当前操作!" + dets);
|
|
|
+ }
|
|
|
+ dets = baseDao
|
|
|
+ .getJdbcTemplate()
|
|
|
+ .queryForObject(
|
|
|
+ "select wm_concat(pd_piclass||'['||pd_inoutno||']行号['||pd_pdno||']') from ProdIODetail where pd_piid=? and nvl(pd_whcode,' ')=' '",
|
|
|
+ String.class, pi_id);
|
|
|
+ if (dets != null) {
|
|
|
+ BaseUtil.showError("明细行仓库为空,不允许进行当前操作!" + dets);
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 限制当仓库编号不为空时,明细行仓库至少有一行与主记录一致;为空则不判断
|
|
|
+ */
|
|
|
+
|
|
|
+ /*
|
|
|
+ * 暂不启用该逻辑限制 int c = baseDao.getCountByCondition(
|
|
|
+ * "ProdInOut left join ProdIODetail on pi_id=pd_piid", "pi_id=" + pi_id
|
|
|
+ * +
|
|
|
+ * " and ((NVL(pd_whcode,' ')=nvl(pi_whcode,' ') AND pi_whcode IS NOT NULL) or pi_whcode is null )"
|
|
|
+ * ); if (c < 1) { BaseUtil.showError("无一明细仓库与主表仓库一致,不允许进行当前操作!"); }
|
|
|
+ */
|
|
|
+ if (!caller.equals("ProdInOut!StockProfit") && !caller.equals("ProdInOut!StockLoss")) {
|
|
|
+ dets = baseDao
|
|
|
+ .getJdbcTemplate()
|
|
|
+ .queryForObject(
|
|
|
+ "select wm_concat(pd_pdno) from ProdIODetail inner join Prodinout on pd_piid=pi_id left join product on pr_code=pd_prodcode where "
|
|
|
+ + "pd_piid=? and round(pd_outqty+pd_inqty,0)<>pd_outqty+pd_inqty and pd_status=0 and NVL(pr_precision,0)=0 and NVL(pr_groupcode,' ')<>'用品' ",
|
|
|
+ String.class, pi_id);
|
|
|
+ if (dets != null) {
|
|
|
+ BaseUtil.showError("计算精度是0的物料不能以小数出入库!行号:" + dets);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (baseDao.isDBSetting("warehouseCheck") || baseDao.isDBSetting(caller, "warehouseCheck")) {
|
|
|
+ // 出入库单主记录与明细行仓库必须一致
|
|
|
+ dets = baseDao
|
|
|
+ .getJdbcTemplate()
|
|
|
+ .queryForObject(
|
|
|
+ "select wm_concat(pd_piclass||'['||pd_inoutno||']行号['||pd_pdno||']') from ProdIODetail left join ProdInOut on pd_piid=pi_id where pi_id=? and (nvl(pi_whcode,' ')<>nvl(pd_whcode,' ') or nvl(pi_purpose,' ')<>nvl(pd_inwhcode,' '))",
|
|
|
+ String.class, pi_id);
|
|
|
+ if (dets != null) {
|
|
|
+ BaseUtil.showError("明细行仓库与当前单主表仓库不一致,不允许进行当前操作!" + dets);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ dets = baseDao
|
|
|
+ .getJdbcTemplate()
|
|
|
+ .queryForObject(
|
|
|
+ "select wmsys.wm_concat(pd_piclass||':'||pd_inoutno||',行:'||pd_pdno||',仓库:'||pd_whcode) from prodiodetail left join warehouse on wh_code=pd_whcode where pd_piid=? and nvl(pd_whcode,' ')<>' ' and nvl(wh_statuscode,' ')='DISABLE'",
|
|
|
+ String.class, pi_id);
|
|
|
+ if (dets != null) {
|
|
|
+ BaseUtil.showError("仓库已禁用,不允许进行当前操作!" + dets);
|
|
|
+ }
|
|
|
+ dets = baseDao
|
|
|
+ .getJdbcTemplate()
|
|
|
+ .queryForObject(
|
|
|
+ "select wmsys.wm_concat(pd_piclass||':'||pd_inoutno||',行:'||pd_pdno||',仓库:'||pd_whcode) from prodiodetail left join warehouse on wh_code=pd_whcode where pd_piid=? and nvl(pd_whcode,' ')<>' ' and pd_whcode not in (select wh_code from warehouse)",
|
|
|
+ String.class, pi_id);
|
|
|
+ if (dets != null) {
|
|
|
+ BaseUtil.showError("仓库不存在,不允许进行当前操作!" + dets);
|
|
|
+ }
|
|
|
+ String maxprice = baseDao.getDBSetting(caller, "maxPrice");
|
|
|
+ if (maxprice != null) {
|
|
|
+ dets = baseDao
|
|
|
+ .getJdbcTemplate()
|
|
|
+ .queryForObject(
|
|
|
+ "select wmsys.wm_concat(pd_piclass||':'||pd_inoutno||',行:'||pd_pdno||',单价:'||pd_price) from prodiodetail where pd_piid=? and nvl(pd_price,0)>?",
|
|
|
+ String.class, pi_id, maxprice);
|
|
|
+ if (dets != null) {
|
|
|
+ BaseUtil.showError("单价超过设置上限,不允许进行当前操作!" + dets);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if ("ProdInOut!Picking".equals(caller) || "ProdInOut!Make!Give".equals(caller) || "ProdInOut!Make!Return".equals(caller)
|
|
|
+ || "ProdInOut!OutsidePicking".equals(caller) || "ProdInOut!OutsideReturn".equals(caller)
|
|
|
+ || "ProdInOut!OSMake!Give".equals(caller) || "ProdInOut!Make!In".equals(caller)
|
|
|
+ || "ProdInOut!PartitionStockIn".equals(caller) || "ProdInOut!OutsideCheckIn".equals(caller)
|
|
|
+ || "ProdInOut!OutesideCheckReturn".equals(caller)) {
|
|
|
+ dets = baseDao
|
|
|
+ .getJdbcTemplate()
|
|
|
+ .queryForObject(
|
|
|
+ "select wm_concat(pd_pdno) from ProdIODetail where pd_piid=? and pd_piclass in ('生产领料单','生产补料单','生产退料单','委外领料单','委外退料单','委外补料单') and not exists (select 1 from make left join makematerial on ma_id=mm_maid where pd_ordercode=ma_code and pd_orderdetno=mm_detno)",
|
|
|
+ String.class, pi_id);
|
|
|
+ if (dets != null) {
|
|
|
+ BaseUtil.showError("工单+序号不存在,不允许进行当前操作!行号:" + dets);
|
|
|
+ }
|
|
|
+ dets = baseDao
|
|
|
+ .getJdbcTemplate()
|
|
|
+ .queryForObject(
|
|
|
+ "select wm_concat(pd_pdno) from ProdIODetail left join Prodinout on pd_piid=pi_id left join make on ma_code=pd_ordercode where "
|
|
|
+ + "pd_piid=? and nvl(pi_cardcode,' ')<>nvl(ma_vendcode,' ') and pd_piclass in ('委外退料单','委外验退单','委外领料单') "
|
|
|
+ + "and nvl(pd_ordercode,' ')<>' ' and not exists (select 1 from makecraft where mc_code=pd_jobcode and mc_tasktype='工序委外单')",
|
|
|
+ String.class, pi_id);
|
|
|
+ if (dets != null) {
|
|
|
+ BaseUtil.showError("明细委外单委外商与单据委外商不一致,不允许进行当前操作!行号:" + dets);
|
|
|
+ }
|
|
|
+
|
|
|
+ dets = baseDao
|
|
|
+ .getJdbcTemplate()
|
|
|
+ .queryForObject(
|
|
|
+ "select wm_concat(pd_pdno) from ProdIODetail where nvl(pd_jobcode,' ')<>' ' and not exists (select 1 from makecraft where pd_jobcode=mc_code "
|
|
|
+ + "and mc_tasktype='工序委外单') and pd_piclass in ('委外退料单','委外验退单','委外领料单') and pd_piid=?", String.class,
|
|
|
+ pi_id);
|
|
|
+ if (dets != null) {
|
|
|
+ BaseUtil.showError("明细工序委外单不存在,不允许进行当前操作!行号:" + dets);
|
|
|
+ }
|
|
|
+
|
|
|
+ dets = baseDao
|
|
|
+ .getJdbcTemplate()
|
|
|
+ .queryForObject(
|
|
|
+ "select wm_concat(pd_pdno) from ProdIODetail left join Prodinout on pd_piid=pi_id left join makecraft on mc_code=pd_jobcode where "
|
|
|
+ + "pd_piid=? and nvl(pi_cardcode,' ')<>nvl(mc_vendcode,' ') and pd_piclass in ('委外退料单','委外验退单','委外领料单') "
|
|
|
+ + "and nvl(pd_ordercode,' ')<>' ' and exists (select 1 from makecraft where mc_code=pd_jobcode and mc_tasktype='工序委外单') ",
|
|
|
+ String.class, pi_id);
|
|
|
+ if (dets != null) {
|
|
|
+ BaseUtil.showError("委外商与工序委外单委外商不一致,不允许进行当前操作!行号:" + dets);
|
|
|
+ }
|
|
|
+ dets = baseDao
|
|
|
+ .getJdbcTemplate()
|
|
|
+ .queryForObject(
|
|
|
+ "select wm_concat('工单:'||pd_ordercode||'序号:'||pd_orderdetno) from (select pd_ordercode,pd_orderdetno,sum(pd_inqty) pd_inqty,max(mm_yqty)mm_yqty,max(mm_gqty)mm_gqty from ProdIODetail left join make on ma_code=pd_ordercode left join makematerial on ma_id=mm_maid and mm_detno=pd_orderdetno where pd_piid=? and pd_piclass='拆件入库单' group by pd_ordercode,pd_orderdetno)A where mm_yqty+pd_inqty>mm_gqty and mm_gqty>0 ",
|
|
|
+ String.class, pi_id);
|
|
|
+ if (dets != null) {
|
|
|
+ BaseUtil.showError("拆件入库数不能大于工单允许可拆件入库数!" + dets);
|
|
|
+ }
|
|
|
+ dets = baseDao
|
|
|
+ .getJdbcTemplate()
|
|
|
+ .queryForObject(
|
|
|
+ "select wm_concat('行号:'||pd_pdno||'工单:'||pd_ordercode) from ProdIODetail left join make on ma_code=pd_ordercode left join makekind ON mk_name=ma_kind where pd_piid=? and pd_piclass='拆件入库单' and mk_type='S'",
|
|
|
+ String.class, pi_id);
|
|
|
+ if (dets != null) {
|
|
|
+ BaseUtil.showError("拆件单明细中存在制造单的类型是标准!" + dets);
|
|
|
+ }
|
|
|
+
|
|
|
+ dets = baseDao
|
|
|
+ .getJdbcTemplate()
|
|
|
+ .queryForObject(
|
|
|
+ "select wm_concat(pd_pdno) from prodinout left join ProdIODetail on pd_piid=pi_id left join make on ma_code=pd_ordercode where pd_piid=? and NVL(ma_statuscode,' ')<>'AUDITED' and pi_statuscode='UNPOST' and pd_piclass in ('完工入库单','拆件入库单','委外验收单','生产领料单','生产补料单','生产退料单','委外领料单','委外退料单','委外补料单') and nvl(pd_ordercode,' ')<>' ' ",
|
|
|
+ String.class, pi_id);
|
|
|
+ if (dets != null) {
|
|
|
+ BaseUtil.showError("工单不存在或者状态不等于已审核,不允许进行当前操作!行号:" + dets);
|
|
|
+ }
|
|
|
+
|
|
|
+ dets = baseDao
|
|
|
+ .getJdbcTemplate()
|
|
|
+ .queryForObject(
|
|
|
+ "select wm_concat(pd_pdno) from ProdIODetail left join Prodinout on pd_piid=pi_id left join make on ma_code=pd_ordercode left join MakeKind on mk_name=ma_kind "
|
|
|
+ + "where pd_piid=? and nvl(pd_whcode,' ')<>' ' and nvl(mk_whcodes,' ')<>' ' and pd_whcode not in (select column_value from table(parsestring(mk_whcodes,'#'))) "
|
|
|
+ + "and pd_piclass in ('完工入库单','委外验收单') and nvl(pd_ordercode,' ')<>' ' and nvl(ProdIODetail.pd_status,0)=0",
|
|
|
+ String.class, pi_id);
|
|
|
+ if (dets != null) {
|
|
|
+ BaseUtil.showError("明细仓库与工单类型允许入库仓库不一致,不允许进行当前操作!行号:" + dets);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if ("ProdInOut!OutesideCheckReturn".equals(caller)) {
|
|
|
+ dets = baseDao
|
|
|
+ .getJdbcTemplate()
|
|
|
+ .queryForObject(
|
|
|
+ "select wm_concat(pd_pdno) from ProdIODetail where pd_piid=? and pd_piclass in ('委外验退单') and not exists (select 1 from make where pd_ordercode=ma_code and pd_prodcode=ma_prodcode) "
|
|
|
+ + "and not exists (select 1 from makecraft where pd_jobcode=mc_code and mc_tasktype='工序委外单' and pd_prodcode=mc_prodcode)",
|
|
|
+ String.class, pi_id);
|
|
|
+ if (dets != null) {
|
|
|
+ BaseUtil.showError("委外单+物料编号不存在,不允许进行当前操作!行号:" + dets);
|
|
|
+ }
|
|
|
+
|
|
|
+ dets = baseDao
|
|
|
+ .getJdbcTemplate()
|
|
|
+ .queryForObject(
|
|
|
+ "select wm_concat(pd_pdno) from ProdIODetail left join Prodinout on pd_piid=pi_id left join Make on ma_code=pd_ordercode where pd_piid=? and nvl(pi_currency,' ')<>nvl(ma_currency,' ')"
|
|
|
+ + " and not exists (select 1 from makecraft where pd_jobcode=mc_code and mc_tasktype='工序委外单')"
|
|
|
+ + " and pd_piclass in ('委外验退单') and nvl(pd_ordercode,' ')<>' '", String.class, pi_id);
|
|
|
+ if (dets != null) {
|
|
|
+ BaseUtil.showError("明细委外单与单据币别不一致,不允许进行当前操作!行号:" + dets);
|
|
|
+ }
|
|
|
+
|
|
|
+ dets = baseDao.getJdbcTemplate().queryForObject(
|
|
|
+ "select wm_concat(pd_pdno) from ProdIODetail left join Prodinout on pd_piid=pi_id left join MakeCraft on mc_makecode=pd_ordercode "
|
|
|
+ + " and mc_code =pd_jobcode where pd_piid=? and nvl(pi_currency,' ')<>nvl(mc_currency,' ')"
|
|
|
+ + " and exists (select 1 from makecraft where pd_jobcode=mc_code and mc_tasktype='工序委外单')"
|
|
|
+ + " and pd_piclass in ('委外验退单') and nvl(pd_ordercode,' ')<>' '", String.class, pi_id);
|
|
|
+ if (dets != null) {
|
|
|
+ BaseUtil.showError("明细委外单与单据币别不一致,不允许进行当前操作!行号:" + dets);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if ("ProdInOut!PurcCheckin".equals(caller) || "ProdInOut!PurcCheckout".equals(caller) || "ProdInOut!DefectIn".equals(caller)
|
|
|
+ || "ProdInOut!DefectOut".equals(caller)) {
|
|
|
+ dets = baseDao
|
|
|
+ .getJdbcTemplate()
|
|
|
+ .queryForObject(
|
|
|
+ "select wm_concat(pi_inoutno) from ProdInOut where pi_id=? and pi_class in ('采购验收单','采购验退单') and (pi_cardcode,pi_title) not in (select ve_code,ve_name from vendor)",
|
|
|
+ String.class, pi_id);
|
|
|
+ if (dets != null) {
|
|
|
+ BaseUtil.showError("单据中供应商编号,供应商名称在供应商资料中不存在!");
|
|
|
+ }
|
|
|
+ dets = baseDao
|
|
|
+ .getJdbcTemplate()
|
|
|
+ .queryForObject(
|
|
|
+ "select wm_concat(pi_inoutno) from ProdInOut where pi_id=? and pi_class in ('采购验收单','采购验退单') and (pi_receivecode,pi_receivename) not in (select ve_code,ve_name from vendor)",
|
|
|
+ String.class, pi_id);
|
|
|
+ if (dets != null) {
|
|
|
+ BaseUtil.showError("单据中应付供应商编号,应付供应商名称在供应商资料中不存在!");
|
|
|
+ }
|
|
|
+ dets = baseDao
|
|
|
+ .getJdbcTemplate()
|
|
|
+ .queryForObject(
|
|
|
+ "select wm_concat(pd_pdno) from ProdIODetail where pd_piid=?"
|
|
|
+ + " and pd_piclass in ('采购验收单','采购验退单') and nvl(pd_ordercode,' ')<>' ' and not exists (select pd_code,pd_pdno from purchasedetail where pd_code=ProdIODetail.pd_ordercode and pd_pdno=ProdIODetail.pd_orderdetno)",
|
|
|
+ String.class, pi_id);
|
|
|
+ if (dets != null) {
|
|
|
+ BaseUtil.showError("采购单号+采购序号不存在,不允许进行当前操作!行号:" + dets);
|
|
|
+ }
|
|
|
+ dets = baseDao
|
|
|
+ .getJdbcTemplate()
|
|
|
+ .queryForObject(
|
|
|
+ "select wm_concat(pd_pdno) from ProdIODetail where pd_piid=?"
|
|
|
+ + " and not exists(select pd_code,pd_pdno from purchasedetail p where p.pd_prodcode=ProdIODetail.pd_prodcode and p.pd_code=ProdIODetail.pd_ordercode and p.pd_pdno=ProdIODetail.pd_orderdetno ) and pd_piclass in ('采购验收单','采购验退单') and nvl(pd_ordercode,' ')<>' ' ",
|
|
|
+ String.class, pi_id);
|
|
|
+ if (dets != null) {
|
|
|
+ BaseUtil.showError("采购单号+采购序号不存在,不允许进行当前操作!行号:" + dets);
|
|
|
+ }
|
|
|
+ dets = baseDao.getJdbcTemplate().queryForObject(
|
|
|
+ "select wm_concat(pd_pdno) from ProdIODetail left join PurchaseDetail on pd_ordercode=pd_code and pd_orderdetno=pd_pdno where "
|
|
|
+ + "pd_piid=? and nvl(pd_mrpstatuscode,' ') in ('FREEZE','FINISH') and pd_piclass in ('采购验收单','采购验退单') "
|
|
|
+ + "and nvl(pd_ordercode,' ')<>' '", String.class, pi_id);
|
|
|
+ if (dets != null) {
|
|
|
+ BaseUtil.showError("采购单明细已冻结或者已结案,不允许进行当前操作!行号:" + dets);
|
|
|
+ }
|
|
|
+ dets = baseDao.getJdbcTemplate().queryForObject(
|
|
|
+ "select wm_concat(pd_pdno) from ProdIODetail left join PurchaseDetail on pd_ordercode=pd_code and pd_orderdetno=pd_pdno where "
|
|
|
+ + "pd_piid=? and nvl(pd_mrpstatuscode,' ') in ('FREEZE','FINISH') and pd_piclass in ('不良品入库单','不良品出库单') "
|
|
|
+ + "and nvl(pd_ordercode,' ')<>' ' and nvl(pd_qctype,' ')='采购检验单'", String.class, pi_id);
|
|
|
+ if (dets != null) {
|
|
|
+ BaseUtil.showError("采购单明细已冻结或者已结案,不允许进行当前操作!行号:" + dets);
|
|
|
+ }
|
|
|
+ dets = baseDao.getJdbcTemplate().queryForObject(
|
|
|
+ "select wm_concat(pd_pdno) from ProdIODetail left join Make on pd_ordercode=ma_code where "
|
|
|
+ + "pd_piid=? and nvl(ma_statuscode,' ') in ('FREEZE','FINISH') and pd_piclass in ('不良品入库单','不良品出库单') "
|
|
|
+ + "and nvl(pd_ordercode,' ')<>' ' and nvl(pd_qctype,' ')='委外检验单'", String.class, pi_id);
|
|
|
+ if (dets != null) {
|
|
|
+ BaseUtil.showError("明细行委外单已冻结或者已结案,不允许进行当前操作!行号:" + dets);
|
|
|
+ }
|
|
|
+ if (!baseDao.isDBSetting(caller, "noLimitVendor")) {
|
|
|
+ dets = baseDao.getJdbcTemplate().queryForObject(
|
|
|
+ "select wm_concat(pd_pdno) from ProdIODetail left join Prodinout on pd_piid=pi_id left join Purchase on pu_code=pd_ordercode where "
|
|
|
+ + "pd_piid=? and nvl(pi_cardcode,' ')<>nvl(pu_vendcode,' ') and pd_piclass in ('采购验收单','采购验退单') "
|
|
|
+ + "and nvl(pd_ordercode,' ')<>' '", String.class, pi_id);
|
|
|
+ if (dets != null) {
|
|
|
+ BaseUtil.showError("明细采购单与单据供应商不一致,不允许进行当前操作!行号:" + dets);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!baseDao.isDBSetting(caller, "allowARCust")) {
|
|
|
+ dets = baseDao
|
|
|
+ .getJdbcTemplate()
|
|
|
+ .queryForObject(
|
|
|
+ "select wm_concat(pd_pdno) from ProdIODetail left join Prodinout on pd_piid=pi_id left join Purchase on pu_code=pd_ordercode where "
|
|
|
+ + "pd_piid=? and nvl(pi_receivecode,' ')<>nvl(pu_receivecode,' ') and pd_piclass in ('采购验收单','采购验退单') and nvl(pd_ordercode,' ')<>' '",
|
|
|
+ String.class, pi_id);
|
|
|
+ if (dets != null) {
|
|
|
+ BaseUtil.showError("明细采购单与单据应付供应商不一致,不允许进行当前操作!行号:" + dets);
|
|
|
+ }
|
|
|
+ dets = baseDao
|
|
|
+ .getJdbcTemplate()
|
|
|
+ .queryForObject(
|
|
|
+ "select wm_concat(pd_pdno) from ProdIODetail left join Prodinout on pd_piid=pi_id left join Purchase on pu_code=pd_ordercode where pd_piid=? and nvl(pi_currency,' ')<>nvl(pu_currency,' ')"
|
|
|
+ + " and pd_piclass in ('采购验收单','采购验退单') and nvl(pd_ordercode,' ')<>' '", String.class, pi_id);
|
|
|
+ if (dets != null) {
|
|
|
+ BaseUtil.showError("明细采购单与单据币别不一致,不允许进行当前操作!行号:" + dets);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ dets = baseDao
|
|
|
+ .getJdbcTemplate()
|
|
|
+ .queryForObject(
|
|
|
+ "select wm_concat('行号:'||pd_pdno||'收料合格数量:'||ved_okqty) from ProdIODetail left join QUA_VerifyApplyDetailDet on pd_qcid=ved_id where pd_piid=? and nvl(pd_qcid,0)<>0 and nvl(pd_inqty,0)>nvl(ved_okqty,0) and pd_piclass in ('采购验收单')",
|
|
|
+ String.class, pi_id);
|
|
|
+ if (dets != null) {
|
|
|
+ BaseUtil.showError("明细行入库数量大于收料合格数量!" + dets);
|
|
|
+ }
|
|
|
+ dets = baseDao
|
|
|
+ .getJdbcTemplate()
|
|
|
+ .queryForObject(
|
|
|
+ "select wm_concat('行号:'||pd_pdno||'收料不合格数量:'||ved_ngqty) from ProdIODetail left join QUA_VerifyApplyDetailDet on pd_qcid=ved_id where pd_piid=? and nvl(pd_qcid,0)<>0 and nvl(pd_inqty,0)>nvl(ved_ngqty,0) and pd_piclass in ('不良品入库单')",
|
|
|
+ String.class, pi_id);
|
|
|
+ if (dets != null) {
|
|
|
+ BaseUtil.showError("明细行入库数量大于收料不合格数量!" + dets);
|
|
|
+ }
|
|
|
+ dets = baseDao
|
|
|
+ .getJdbcTemplate()
|
|
|
+ .queryForObject(
|
|
|
+ "select wm_concat(pd_pdno) from ProdIODetail left join Prodinout on pd_piid=pi_id left join Purchase on pu_code=pd_ordercode left join purchasekind on pk_name=pu_kind "
|
|
|
+ + "where pd_piid=? and nvl(pd_whcode,' ')<>' ' and nvl(pk_whcodes,' ')<>' ' and pd_whcode not in (select column_value from table(parsestring(pk_whcodes,'#'))) "
|
|
|
+ + "and pd_piclass in ('采购验收单') and nvl(pd_ordercode,' ')<>' '", String.class, pi_id);
|
|
|
+ if (dets != null) {
|
|
|
+ BaseUtil.showError("明细仓库与采购单类型允许入仓库不一致,不允许进行当前操作!行号:" + dets);
|
|
|
+ }
|
|
|
+ if ("ProdInOut!PurcCheckin".equals(caller)) {
|
|
|
+ dets = baseDao
|
|
|
+ .getJdbcTemplate()
|
|
|
+ .queryForObject(
|
|
|
+ "select wm_concat(pd_pdno) from ProdIODetail left join PurchaseDetail on PurchaseDetail.pd_code=ProdIODetail.pd_ordercode and PurchaseDetail.pd_pdno=ProdIODetail.pd_orderdetno "
|
|
|
+ + "where pd_piid=? and nvl(PurchaseDetail.pd_yqty,0)>nvl(PurchaseDetail.pd_qty,0)-nvl(PurchaseDetail.pd_frozenqty,0) "
|
|
|
+ + "and pd_piclass in ('采购验收单') and nvl(ProdIODetail.pd_ordercode,' ')<>' '", String.class, pi_id);
|
|
|
+ if (dets != null) {
|
|
|
+ BaseUtil.showError("明细采购订单已转数大于采购订单数量-已冻结数量,不允许进行当前操作!行号:" + dets);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if ("ProdInOut!SaleBorrow".equals(caller) || "ProdInOut!OtherPurcIn".equals(caller)) {
|
|
|
+ dets = baseDao
|
|
|
+ .getJdbcTemplate()
|
|
|
+ .queryForObject(
|
|
|
+ "select wm_concat(pd_piclass||'['||pd_inoutno||']行号['||pd_pdno||']') from ProdIODetail left join Prodinout on pd_piid=pi_id left join BorrowCargoType on bt_name=pi_outtype "
|
|
|
+ + "where pd_piid=? and nvl(pd_whcode,' ')<>' ' and nvl(bt_whcodes,' ')<>' ' and pd_whcode not in (select column_value from table(parsestring(bt_whcodes,'#'))) "
|
|
|
+ + "and pd_piclass in ('借货出货单','其它采购入库单')", String.class, pi_id);
|
|
|
+ if (dets != null) {
|
|
|
+ BaseUtil.showError("明细仓库与借货类型允许出入仓库不一致,不允许进行当前操作!" + dets);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if ("ProdInOut!Sale".equals(caller) || "ProdInOut!SaleReturn".equals(caller) || "ProdInOut!OtherOut".equals(caller)
|
|
|
+ || "ProdInOut!ExchangeOut".equals(caller) || "ProdInOut!SaleAppropriationOut".equals(caller)) {
|
|
|
+ if (baseDao.isDBSetting(caller, "allowDifProd")) {
|
|
|
+ dets = baseDao
|
|
|
+ .getJdbcTemplate()
|
|
|
+ .queryForObject(
|
|
|
+ "select wm_concat(pd_pdno) from ProdIODetail where pd_piid=? and not exists(select sd_code,sd_detno from saledetail where sd_code=pd_ordercode and sd_detno=pd_orderdetno and sd_statuscode='AUDITED')"
|
|
|
+ + " and pd_piclass in ('出货单','销售退货单','其它出库单','换货出库单','销售拨出单') and nvl(pd_ordercode,' ')<>' ' and nvl(pd_ioid,0)=0",
|
|
|
+ String.class, pi_id);
|
|
|
+ if (dets != null) {
|
|
|
+ BaseUtil.showError("销售单号+销售序号不存在或者状态不等于已审核,不允许进行当前操作!行号:" + dets);
|
|
|
+ }
|
|
|
+ } else if (baseDao.isDBSetting(caller, "SaleWithProdRelation")) {
|
|
|
+ dets = baseDao
|
|
|
+ .getJdbcTemplate()
|
|
|
+ .queryForObject(
|
|
|
+ "select wm_concat(pd_pdno) from ProdIODetail where pd_piid=? and "
|
|
|
+ + "not exists (select sd_code,sd_detno from saledetail left join ProdRelation on (sd_prodcode=prr_soncode or (nvl(prr_ifonewa,0)=0 and sd_prodcode=prr_repcode)) "
|
|
|
+ + "where sd_code=pd_ordercode and sd_detno=pd_orderdetno and (nvl(sd_prodcode,' ')=nvl(pd_prodcode,' ') or nvl(prr_repcode ,' ')=nvl(pd_prodcode,' ') or nvl(prr_soncode ,' ')=nvl(pd_prodcode,' ')))"
|
|
|
+ + " and pd_piclass in ('出货单','销售退货单','其它出库单','换货出库单','销售拨出单') and nvl(pd_ordercode,' ')<>' ' and nvl(pd_ioid,0)=0",
|
|
|
+ String.class, pi_id);
|
|
|
+ if (dets != null) {
|
|
|
+ BaseUtil.showError("销售单号+销售序号+物料编号不存在或者状态不等于已审核,不允许进行当前操作!行号:" + dets);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ dets = baseDao
|
|
|
+ .getJdbcTemplate()
|
|
|
+ .queryForObject(
|
|
|
+ "select wm_concat(pd_pdno) from ProdIODetail where pd_piid=? and not exists(select sd_code,sd_detno from saledetail where sd_prodcode=pd_prodcode and sd_code=pd_ordercode and sd_detno=pd_orderdetno )"
|
|
|
+ + " and pd_piclass in ('出货单','销售退货单','其它出库单','换货出库单','销售拨出单') and nvl(pd_ordercode,' ')<>' ' and nvl(pd_ioid,0)=0",
|
|
|
+ String.class, pi_id);
|
|
|
+ if (dets != null) {
|
|
|
+ BaseUtil.showError("销售单号+销售序号+物料编号不存在,不允许进行当前操作!行号:" + dets);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (baseDao.isDBSetting("useMachineNo")) {
|
|
|
+ dets = baseDao
|
|
|
+ .getJdbcTemplate()
|
|
|
+ .queryForObject(
|
|
|
+ "select wm_concat('物料'||pd_prodcode||'总数量'||qty||'已采集数'||yqty) from (SELECT pd_piid, pd_prodcode, pd_inoutno, nvl(sum(nvl(pd_inqty,0)+nvl(pd_outqty,0)),0) qty from prodiodetail where pd_piid=? group by pd_piid,pd_inoutno,pd_prodcode) left join (select pim_piid,pim_prodcode,count(1) yqty from prodiomac group by pim_piid,pim_prodcode) on pim_piid=pd_piid and pim_prodcode=pd_prodcode where nvl(qty,0)<>nvl(yqty,0) and nvl(yqty,0)<>0",
|
|
|
+ String.class, pi_id);
|
|
|
+ if (dets != null) {
|
|
|
+ BaseUtil.showError("单据+物料数量跟机器号数量不一致,不允许进行当前操作!行号:" + dets);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!(baseDao.isDBSetting("ProdInOut!Sale", "custatus"))) {
|
|
|
+ if (baseDao.isDBSetting("Sale", "zeroOutWhenHung")) {// 客户挂起时,订单单价为0不限制出货
|
|
|
+ dets = baseDao
|
|
|
+ .getJdbcTemplate()
|
|
|
+ .queryForObject(
|
|
|
+ "select wm_concat(pi_cardcode) from ProdInOut left join customer on pi_cardcode=cu_code where pi_id = ? and pi_class in ('出货单') "
|
|
|
+ + "and cu_status='挂起' and not exists (select 1 from prodiodetail left join saledetail on pd_ordercode=sd_code and pd_orderdetno=sd_detno"
|
|
|
+ + " where pd_piid=pi_id and nvl(pd_ordercode,' ')<>' ' and nvl(sd_price,0)=0)", String.class,
|
|
|
+ pi_id);
|
|
|
+ if (dets != null) {
|
|
|
+ BaseUtil.showError("客户资料状态为挂起,且订单单价不为0,不允许进行当前操作!客户号:" + dets);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ dets = baseDao
|
|
|
+ .getJdbcTemplate()
|
|
|
+ .queryForObject(
|
|
|
+ "select wm_concat(pi_cardcode) from ProdInOut left join customer on pi_cardcode=cu_code where pi_id = ? and pi_class in ('出货单','其它出库单','换货出库单','销售拨出单') and cu_status='挂起'",
|
|
|
+ String.class, pi_id);
|
|
|
+ if (dets != null) {
|
|
|
+ BaseUtil.showError("客户资料状态为挂起,不允许进行当前操作!客户号:" + dets);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ if (!baseDao.isDBSetting(caller, "allowARCust")) {
|
|
|
+ dets = baseDao
|
|
|
+ .getJdbcTemplate()
|
|
|
+ .queryForObject(
|
|
|
+ "select wm_concat(pd_pdno) from ProdIODetail left join Prodinout on pd_piid=pi_id left join Sale on sa_code=pd_ordercode where pd_piid=? and nvl(pi_cardcode,' ')<>nvl(sa_custcode,' ')"
|
|
|
+ + " and pd_piclass in ('出货单','销售退货单','其它出库单','换货出库单','销售拨出单') and nvl(pd_ordercode,' ')<>' ' and nvl(pd_ioid,0)=0",
|
|
|
+ String.class, pi_id);
|
|
|
+ if (dets != null) {
|
|
|
+ BaseUtil.showError("明细销售单与单据客户不一致,不允许进行当前操作!行号:" + dets);
|
|
|
+ }
|
|
|
+ dets = baseDao
|
|
|
+ .getJdbcTemplate()
|
|
|
+ .queryForObject(
|
|
|
+ "select wm_concat(pd_pdno) from ProdIODetail left join Prodinout on pd_piid=pi_id left join Sale on sa_code=pd_ordercode where pd_piid=? and nvl(pi_arcode,' ')<>nvl(sa_apcustcode,' ')"
|
|
|
+ + " and pd_piclass in ('出货单','销售退货单') and nvl(pd_ordercode,' ')<>' '", String.class, pi_id);
|
|
|
+ if (dets != null) {
|
|
|
+ BaseUtil.showError("明细销售单与单据应收客户不一致,不允许进行当前操作!行号:" + dets);
|
|
|
+ }
|
|
|
+ dets = baseDao
|
|
|
+ .getJdbcTemplate()
|
|
|
+ .queryForObject(
|
|
|
+ "select wm_concat(pd_pdno) from ProdIODetail left join Prodinout on pd_piid=pi_id left join Sale on sa_code=pd_ordercode where pd_piid=? and nvl(pi_currency,' ')<>nvl(sa_currency,' ')"
|
|
|
+ + " and pd_piclass in ('出货单','销售退货单') and nvl(pd_ordercode,' ')<>' '", String.class, pi_id);
|
|
|
+ if (dets != null) {
|
|
|
+ BaseUtil.showError("明细销售单与单据币别不一致,不允许进行当前操作!行号:" + dets);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ dets = baseDao
|
|
|
+ .getJdbcTemplate()
|
|
|
+ .queryForObject(
|
|
|
+ "select wm_concat(pi_inoutno) from ProdInOut where pi_id=? and pi_class in ('出货单','销售退货单') and (pi_cardcode,pi_title) not in (select cu_code,cu_name from customer)",
|
|
|
+ String.class, pi_id);
|
|
|
+ if (dets != null) {
|
|
|
+ BaseUtil.showError("单据中客户编号,客户名称在客户资料中不存在!");
|
|
|
+ }
|
|
|
+ dets = baseDao
|
|
|
+ .getJdbcTemplate()
|
|
|
+ .queryForObject(
|
|
|
+ "select wm_concat(pi_inoutno) from ProdInOut where pi_id=? and pi_class in ('出货单','销售退货单') and (pi_arcode,pi_arname) not in (select cu_code,cu_name from customer)",
|
|
|
+ String.class, pi_id);
|
|
|
+ if (dets != null) {
|
|
|
+ BaseUtil.showError("单据中应收客户编号,应收客户名称在客户资料中不存在!");
|
|
|
+ }
|
|
|
+ // 销售退货单:退货数量,如退货数量+其它未过账的退货单数量大于销售订单出货数
|
|
|
+ /**
|
|
|
+ * 需考虑状态
|
|
|
+ */
|
|
|
+ dets = baseDao
|
|
|
+ .getJdbcTemplate()
|
|
|
+ .queryForObject(
|
|
|
+ "select wm_concat(pd_pdno) from ProdIODetail b left join SaleDetail on sd_code=pd_ordercode and sd_detno=pd_orderdetno where pd_piid=? and pd_status<99 and pd_piclass='销售退货单' and nvl(pd_ordercode,' ')<>' ' and nvl(pd_inqty,0) + (select nvl(sum(nvl(a.pd_inqty,0)),0) from ProdIODetail a where a.pd_piclass='销售退货单' and a.pd_status<99 and a.pd_ordercode=b.pd_ordercode and a.pd_orderdetno=b.pd_orderdetno and a.pd_id <> b.pd_id) > nvl(sd_sendqty,0)",
|
|
|
+ String.class, pi_id);
|
|
|
+ if (dets != null) {
|
|
|
+ BaseUtil.showError("本次退货数+其它退货数合计大于订单的已发货数量,不允许进行当前操作!行号:" + dets);
|
|
|
+ }
|
|
|
+ if ("ProdInOut!SaleAppropriationOut".equals(caller) || "ProdInOut!OtherOut".equals(caller)) {
|
|
|
+ dets = baseDao
|
|
|
+ .getJdbcTemplate()
|
|
|
+ .queryForObject(
|
|
|
+ "select wm_concat(pd_piclass||'['||pd_inoutno||']行号['||pd_pdno||']') from ProdIODetail where pd_piid=? and (pd_plancode,pd_forecastdetno) not in (select sd_code, sd_detno from saleforecastdetail,saleforecast where sf_id=sd_sfid and sf_code=pd_plancode and sd_detno=pd_forecastdetno and sd_statuscode='AUDITED') and nvl(pd_plancode,' ')<>' '",
|
|
|
+ String.class, pi_id);
|
|
|
+ if (dets != null) {
|
|
|
+ BaseUtil.showError("明细行预测单号+预测序号不存在或者状态不等于已审核,不允许进行当前操作!!" + dets);
|
|
|
+ }
|
|
|
+ dets = baseDao
|
|
|
+ .getJdbcTemplate()
|
|
|
+ .queryForObject(
|
|
|
+ "select wm_concat(pd_piclass||'['||pd_inoutno||']行号['||pd_pdno||']') from ProdIODetail where pd_piid=? and (pd_plancode,pd_forecastdetno) in (select sd_code, sd_detno from saleforecastdetail where nvl(sd_qty,0)=0) and nvl(pd_plancode,' ')<>' '",
|
|
|
+ String.class, pi_id);
|
|
|
+ if (dets != null) {
|
|
|
+ BaseUtil.showError("明细行预测单号+预测序号预测数量等于0,不允许进行当前操作!" + dets);
|
|
|
+ }
|
|
|
+ dets = baseDao
|
|
|
+ .getJdbcTemplate()
|
|
|
+ .queryForObject(
|
|
|
+ "select wm_concat(pd_piclass||'['||pd_inoutno||']行号['||pd_pdno||']') from ProdIODetail left join SaleDetail on pd_ordercode=sd_code and pd_orderdetno=sd_detno where pd_piid=? and pd_piclass in ('销售拨出单','其它出库单') and nvl(pd_outqty+pd_inqty,0)>nvl(sd_qty,0)-nvl(sd_yqty,0) and nvl(pd_ordercode,' ')<>' ' and nvl(pd_ioid,0)=0 and nvl(pd_snid,0)=0",
|
|
|
+ String.class, pi_id);
|
|
|
+ if (dets != null) {
|
|
|
+ BaseUtil.showError("明细行销售单号+销售序号数量大于订单未发货数,不允许进行当前操作!" + dets);
|
|
|
+ }
|
|
|
+ dets = baseDao
|
|
|
+ .getJdbcTemplate()
|
|
|
+ .queryForObject(
|
|
|
+ "select wm_concat(pd_piclass||'['||pd_inoutno||']行号['||pd_pdno||']') from ProdIODetail where pd_piid=? and pd_piclass='销售拨出单' and pd_plancode not in (select a.sf_code from saleforecast a left join saleforecastkind b on (a.sf_kind=b.sf_name or a.sf_kind=b.sf_code) where a.sf_code=pd_plancode and sf_clashoption in ('SEND','发货冲销')) and nvl(pd_plancode,' ')<>' '",
|
|
|
+ String.class, pi_id);
|
|
|
+ if (dets != null) {
|
|
|
+ BaseUtil.showError("预测单录入错误,该预测类型不属于发货冲销!" + dets);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if ("ProdInOut!AppropriationOut".equals(caller) || "ProdInOut!AppropriationIn".equals(caller)
|
|
|
+ || "ProdInOut!SaleAppropriationOut".equals(caller) || "ProdInOut!SaleAppropriationIn".equals(caller)) {
|
|
|
+ dets = baseDao
|
|
|
+ .getJdbcTemplate()
|
|
|
+ .queryForObject(
|
|
|
+ "select wm_concat(pd_pdno) from ProdIODetail,warehouse w1,warehouse w2 where pd_piid=? and pd_whcode=w1.wh_code and pd_inwhcode=w2.wh_code and nvl(w1.wh_nocost,0)<>nvl(w2.wh_nocost,0)",
|
|
|
+ String.class, pi_id);
|
|
|
+ if (dets != null) {
|
|
|
+ BaseUtil.showError("有值和无值仓之间不能相互调拨!行号:" + dets);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ SqlRowList rs = baseDao.queryForRowSet("select * from prodiodetail where pd_piid=?", pi_id);
|
|
|
+ StringBuffer sb = new StringBuffer();
|
|
|
+ while (rs.next()) {
|
|
|
+ int pdid = rs.getInt("pd_id");
|
|
|
+ int ioid = rs.getGeneralInt("pd_ioid");
|
|
|
+ double tqty = rs.getGeneralDouble("pd_inqty") + rs.getGeneralDouble("pd_outqty");
|
|
|
+ double yqty = 0.0;
|
|
|
+ if (ioid > 0) {
|
|
|
+ yqty = baseDao.getSummaryByField("Prodiodetail", "nvl(pd_outqty,0) + nvl(pd_inqty,0)", "pd_ioid=" + ioid + " and pd_id<>"
|
|
|
+ + pdid);
|
|
|
+ Object[] source = baseDao.getFieldsDataByCondition("Prodiodetail", new String[] { "nvl(pd_outqty,0)", "nvl(pd_inqty,0)",
|
|
|
+ "pd_piclass", "pd_inoutno" }, "pd_id=" + ioid);
|
|
|
+ if (source != null) {
|
|
|
+ if (yqty + tqty > Double.parseDouble(source[0].toString()) + Double.parseDouble(source[1].toString())) {
|
|
|
+ sb.append("行号:" + rs.getInt("pd_pdno") + ",数量:" + tqty + ",无法转出." + source[2] + "[" + source[3] + "]已转数量:" + yqty
|
|
|
+ + ",本次数量:" + tqty + "<hr/>");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (sb.length() > 0) {
|
|
|
+ BaseUtil.showError(sb.toString());
|
|
|
+ }
|
|
|
+ // 保税信息判断
|
|
|
+ if (baseDao.isDBSetting("ioWHBondedCheck")) {
|
|
|
+ if ("ProdInOut!PurcCheckin".equals(caller) || "ProdInOut!PurcCheckout".equals(caller)) {
|
|
|
+ dets = baseDao
|
|
|
+ .getJdbcTemplate()
|
|
|
+ .queryForObject(
|
|
|
+ "select wm_concat(pd_pdno) from ProdIODetail left join Prodinout on pd_piid=pi_id left join PurchaseDetail on pd_code=pd_ordercode and pd_pdno=pd_orderdetno left join warehouse on ProdIODetail.pd_whcode=wh_code where pd_piid=? and nvl(PurchaseDetail.pd_bonded,0)<>nvl(wh_bonded,0)"
|
|
|
+ + " and pd_piclass in ('采购验收单','采购验退单') and nvl(pd_ordercode,' ')<>' '", String.class, pi_id);
|
|
|
+ if (dets != null) {
|
|
|
+ BaseUtil.showError("采购单的保税属性与仓库的保税属性不一致,不允许进行当前操作!行号:" + dets);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if ("ProdInOut!OutesideCheckReturn".equals(caller) || "ProdInOut!OutsideCheckIn".equals(caller)) {
|
|
|
+ dets = baseDao
|
|
|
+ .getJdbcTemplate()
|
|
|
+ .queryForObject(
|
|
|
+ "select wm_concat(pd_pdno) from ProdIODetail left join Prodinout on pd_piid=pi_id left join Make on ma_code=pd_ordercode left join warehouse on pd_whcode=wh_code where pd_piid=? and nvl(ma_bonded,0)<>nvl(wh_bonded,0)"
|
|
|
+ + " and pd_piclass in ('委外验退单','委外验收单') and nvl(pd_ordercode,' ')<>' '", String.class, pi_id);
|
|
|
+ if (dets != null) {
|
|
|
+ BaseUtil.showError("委外单的保税属性与仓库的保税属性不一致,不允许进行当前操作!行号:" + dets);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if ("ProdInOut!Make!In".equals(caller) || "ProdInOut!PartitionStockIn".equals(caller)) {
|
|
|
+ dets = baseDao
|
|
|
+ .getJdbcTemplate()
|
|
|
+ .queryForObject(
|
|
|
+ "select wm_concat(pd_pdno) from ProdIODetail left join Prodinout on pd_piid=pi_id left join Make on ma_code=pd_ordercode left join warehouse on pd_whcode=wh_code where pd_piid=? and nvl(ma_bonded,0)<>nvl(wh_bonded,0)"
|
|
|
+ + " and pd_piclass in ('完工入库单','拆件入库单') and nvl(pd_ordercode,' ')<>' '", String.class, pi_id);
|
|
|
+ if (dets != null) {
|
|
|
+ BaseUtil.showError("工单的保税属性与仓库的保税属性不一致,不允许进行当前操作!行号:" + dets);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if ("ProdInOut!Make!Give".equals(caller) || "ProdInOut!Make!Return".equals(caller) || "ProdInOut!Picking".equals(caller)
|
|
|
+ || "ProdInOut!OSMake!Give".equals(caller) || "ProdInOut!OutsideReturn".equals(caller)
|
|
|
+ || "ProdInOut!OutsidePicking".equals(caller)) {
|
|
|
+ dets = baseDao
|
|
|
+ .getJdbcTemplate()
|
|
|
+ .queryForObject(
|
|
|
+ "select wm_concat(pd_piclass||'['||pd_inoutno||']行号['||pd_pdno||']') from ProdIODetail left join Prodinout on pd_piid=pi_id left join Make on ma_code=pd_ordercode left join warehouse on pd_whcode=wh_code where pd_piid=? and nvl(ma_bonded,0)=0 and nvl(wh_bonded,0)<>0"
|
|
|
+ + " and pd_piclass in ('委外补料单','委外退料单','委外领料单') and nvl(pd_ordercode,' ')<>' '", String.class,
|
|
|
+ pi_id);
|
|
|
+ if (dets != null) {
|
|
|
+ BaseUtil.showError("委外单保税属性是非保税,不能发生仓库保税属性是保税的单据!" + dets);
|
|
|
+ }
|
|
|
+ dets = baseDao
|
|
|
+ .getJdbcTemplate()
|
|
|
+ .queryForObject(
|
|
|
+ "select wm_concat(pd_piclass||'['||pd_inoutno||']行号['||pd_pdno||']') from ProdIODetail left join Prodinout on pd_piid=pi_id left join Make on ma_code=pd_ordercode left join warehouse on pd_whcode=wh_code where pd_piid=? and nvl(ma_bonded,0)=0 and nvl(wh_bonded,0)<>0"
|
|
|
+ + " and pd_piclass in ('生产补料单','生产退料单','生产领料单') and nvl(pd_ordercode,' ')<>' '", String.class,
|
|
|
+ pi_id);
|
|
|
+ if (dets != null) {
|
|
|
+ BaseUtil.showError("工单保税属性是非保税,不能发生仓库保税属性是保税的单据!" + dets);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if ("ProdInOut!SaleAppropriationOut".equals(caller) || "ProdInOut!AppropriationOut".equals(caller)) {
|
|
|
+ dets = baseDao
|
|
|
+ .getJdbcTemplate()
|
|
|
+ .queryForObject(
|
|
|
+ "select wm_concat(pd_piclass||'['||pd_inoutno||']行号['||pd_pdno||']') from ProdIODetail left join Prodinout on pd_piid=pi_id left join warehouse a on a.wh_code=pd_whcode left join warehouse b on b.wh_code=pd_inwhcode where pd_piid=? and nvl(a.wh_bonded,0)<>nvl(b.wh_bonded,0)"
|
|
|
+ + " and pd_piclass in ('拨出单','销售拨出单') and nvl(pd_whcode,' ')<>' ' and nvl(pd_inwhcode,' ')<>' '",
|
|
|
+ String.class, pi_id);
|
|
|
+ if (dets != null) {
|
|
|
+ BaseUtil.showError("拨出仓库与拨入仓库仓库的保税属性不一致,不能进行当前操作!" + dets);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // @add20180605 Q:2018050126 最后一张完工入库单或者委外验收单,提交、审核、过账之前限制,不允许存在未过账
|
|
|
+ // 领、退、补单据,未审核的报废单,未过账的委外验退单
|
|
|
+ if (("ProdInOut!OutsideCheckIn".equals(caller) || "ProdInOut!Make!In".equals(caller))
|
|
|
+ && baseDao.isDBSetting(caller, "checkRelBillsStatus")) {
|
|
|
+ // 判断哪些工单是最后一张完工入库单
|
|
|
+ rs = baseDao
|
|
|
+ .queryForRowSet(
|
|
|
+ "select pd_ordercode,pd_pdno from (select pd_ordercode,sum(pd_inqty)inqty,wm_concat(pd_pdno)pd_pdno from prodiodetail where "
|
|
|
+ + "pd_piid=? and pd_piclass in('完工入库单','委外验收单') group by pd_ordercode) A left join make on ma_code=A.pd_ordercode "
|
|
|
+ + "where nvl(ma_madeqty,0)+inqty>=ma_qty", pi_id);
|
|
|
+ String errors = null;
|
|
|
+ while (rs.next()) {
|
|
|
+ dets = baseDao
|
|
|
+ .getJdbcTemplate()
|
|
|
+ .queryForObject(
|
|
|
+ "select wm_concat(pi_class||':'||pi_inoutno) from prodiodetail,ProdInOut WHERE pd_piid=pi_id AND pi_id<>? and pd_ordercode = ? AND pi_statuscode = 'UNPOST' AND pd_status=0 AND (pd_piclass LIKE '生产%' OR pd_piclass LIKE '委外%' OR pd_piclass LIKE '完工%') and rownum<15",
|
|
|
+ String.class, pi_id, rs.getString("pd_ordercode"));
|
|
|
+ if (dets != null) {
|
|
|
+ errors = "行号:" + rs.getString("pd_pdno") + ",工单:" + rs.getString("pd_ordercode") + "存在关联未过账单据!" + dets;
|
|
|
+ }
|
|
|
+ dets = baseDao
|
|
|
+ .getJdbcTemplate()
|
|
|
+ .queryForObject(
|
|
|
+ "SELECT wm_concat(ms_code) FROM MakeScrapdetail,MakeScrap WHERE md_msid=ms_id AND md_mmcode=? AND ms_statuscode in ('ENTERING','COMMITED') AND nvl(md_status,0)=0",
|
|
|
+ String.class, rs.getString("pd_ordercode"));
|
|
|
+ if (dets != null) {
|
|
|
+ if (errors != null) {
|
|
|
+ errors += "<br>未审核的报废单:" + dets;
|
|
|
+ } else {
|
|
|
+ errors = "行号:" + rs.getString("pd_pdno") + ",工单:" + rs.getString("pd_ordercode") + "存在关联未审核的报废单:" + dets;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (errors != null && !"".equals(errors)) {
|
|
|
+ BaseUtil.showError(errors);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void checkCloseMonth(Object pidate) {
|
|
|
+ boolean bool = baseDao.checkIf("PeriodsDetail", "pd_code='MONTH-P' and pd_status=99 and pd_pdno=to_char(to_date('" + pidate
|
|
|
+ + "','yyyy-mm-dd hh24:mi:ss'), 'yyyymm')");
|
|
|
+ if (bool) {
|
|
|
+ BaseUtil.showError("单据日期所属期间已结账,不允许进行当前操作!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void checkFreezeMonth(String caller, Object pidate) {
|
|
|
+ if (!"ProdInOut!CostChange".equals(caller)) {
|
|
|
+ String freeze = baseDao.getDBSetting("freezeMonth");
|
|
|
+ if (freeze != null && !freeze.equals("")) {
|
|
|
+ if (Integer.parseInt(freeze) == DateUtil.getYearmonth(pidate.toString())) {
|
|
|
+ BaseUtil.showError("单据日期所属期间已冻结,不允许进行当前操作!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void allowZeroTax(String caller, Object pi_id) {
|
|
|
+ String currency = baseDao.getDBSetting("defaultCurrency");
|
|
|
+ boolean allowZeroTax = baseDao.isDBSetting(caller, "allowZeroTax");
|
|
|
+ if ("ProdInOut!Sale".equals(caller) || "ProdInOut!SaleReturn".equals(caller)) {
|
|
|
+ allowZeroTax = baseDao.isDBSetting("Sale", "allowZeroTax");
|
|
|
+ }
|
|
|
+ if ("ProdInOut!PurcCheckin".equals(caller) || "ProdInOut!PurcCheckout".equals(caller)) {
|
|
|
+ allowZeroTax = baseDao.isDBSetting("Purchase", "allowZeroTax");
|
|
|
+ }
|
|
|
+ if ("ProdInOut!OutsideCheckIn".equals(caller) || "ProdInOut!OutesideCheckReturn".equals(caller)) {
|
|
|
+ allowZeroTax = baseDao.isDBSetting("Make", "allowZeroTax");
|
|
|
+ }
|
|
|
+ if (!allowZeroTax) {
|
|
|
+ String dets = baseDao.getJdbcTemplate().queryForObject(
|
|
|
+ "select WM_CONCAT(pd_pdno) from ProdIODetail left join ProdInOut on pd_piid=pi_id where nvl(pd_taxrate,0)=0 and pi_currency='"
|
|
|
+ + currency + "' and pi_id=?", String.class, pi_id);
|
|
|
+ if (dets != null) {
|
|
|
+ BaseUtil.showError("本位币税率为0,不允许进行当前操作!行号:" + dets);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 税率强制等于币别表的默认税率
|
|
|
+ private void useDefaultTax(String caller, Object pi_id) {
|
|
|
+ if (baseDao.isDBSetting(caller, "useDefaultTax")) {
|
|
|
+ baseDao.execute("update ProdIODetail set pd_taxrate=(select cr_taxrate from currencys left join ProdInOut on pi_currency=cr_name and cr_statuscode='CANUSE' where pd_piid=pi_id)"
|
|
|
+ + " where pd_piid=" + pi_id);
|
|
|
+ }
|
|
|
+ String defaultTax = baseDao.getDBSetting(caller, "defaultTax");
|
|
|
+ if (defaultTax != null) {
|
|
|
+ // 税率强制等于币别表的默认税率
|
|
|
+ if ("1".equals(defaultTax)) {
|
|
|
+ baseDao.execute("update ProdIODetail set pd_taxrate=(select cr_taxrate from currencys left join ProdInOut on pi_currency=cr_name and cr_statuscode='CANUSE' where pd_piid=pi_id)"
|
|
|
+ + " where pd_piid=" + pi_id);
|
|
|
+ }
|
|
|
+ // 税率强制等于供应商资料的默认税率
|
|
|
+ if ("2".equals(defaultTax)) {
|
|
|
+ if ("ProdInOut!PurcCheckin".equals(caller) || "ProdInOut!PurcCheckout".equals(caller)
|
|
|
+ || "ProdInOut!OutsideCheckIn".equals(caller) || "ProdInOut!OutesideCheckReturn".equals(caller)) {
|
|
|
+ baseDao.execute("update ProdIODetail set pd_taxrate=(select nvl(ve_taxrate,0) from Vendor left join ProdInOut on pi_cardcode=ve_code and ve_auditstatuscode='AUDITED' where pi_id=pd_piid)"
|
|
|
+ + " where pd_piid=" + pi_id);
|
|
|
+ }
|
|
|
+ if ("ProdInOut!SaleReturn".equals(caller) || "ProdInOut!Sale".equals(caller)) {
|
|
|
+ baseDao.execute("update ProdIODetail set pd_taxrate=(select nvl(cu_taxrate,0) from Customer left join ProdInOut on pi_cardcode=cu_code and cu_auditstatuscode='AUDITED' where pi_id=pd_piid)"
|
|
|
+ + " where pd_piid=" + pi_id);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public void checkSendCode(Object pi_id) {
|
|
|
+ SqlRowSet rs = baseDao.getJdbcTemplate().queryForRowSet("select pd_pdno from prodinout left join prodiodetail on pi_id=pd_piid left join VerifyApply on va_code=pd_vacode where pi_id="
|
|
|
+ + pi_id + " and nvl(pi_sendcode,' ')<>nvl(va_sendcode,' ')");
|
|
|
+ if (rs.next()) {
|
|
|
+ BaseUtil.showError("行号:" + rs.getInt("pd_pdno") + "送货单号不一致,不允许操作");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void inOverNow(String caller,Object id){
|
|
|
+ if (baseDao.isDBSetting("inOverNow") && baseDao.isProdIn(caller) ) {
|
|
|
+ String dets = baseDao
|
|
|
+ .getJdbcTemplate()
|
|
|
+ .queryForObject(
|
|
|
+ "select wm_concat(PD_PDNO) from ProdIODetail left join ProdInOut on pd_piid = pi_id "
|
|
|
+ + " where pi_id = ? and pd_prodmadedate is not null and to_char(pd_prodmadedate,'yyyy-mm') > to_char(sysdate,'yyyy-mm') ",
|
|
|
+ String.class, id);
|
|
|
+ if (dets != null) {
|
|
|
+ BaseUtil.showError("行:"+dets+",明细生产日期不能大于系统日期所在年月!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void factorycheck(Object pi_id, String caller) {
|
|
|
+ if (baseDao.isDBSetting("MpsDesk", "mrpSeparateFactory")) {
|
|
|
+ // 采购验收单、采购验退单:明细行采购单所属工厂与仓库的所属工厂不一致,,不允许进行当前操作
|
|
|
+ String dets = baseDao
|
|
|
+ .getJdbcTemplate()
|
|
|
+ .queryForObject(
|
|
|
+ "select wm_concat(pd_pdno) from ProdIODetail left join PurchaseDetail on ProdIODetail.pd_ordercode=PurchaseDetail.pd_code and ProdIODetail.pd_orderdetno=PurchaseDetail.pd_pdno left join Warehouse on ProdIODetail.pd_whcode=wh_code left join product on ProdIODetail.pd_prodcode=pr_code where pd_piid=? and nvl(PR_ISGROUPPURC,0)=0 and nvl(PurchaseDetail.pd_factory,' ')<>nvl(wh_factory,' ') and nvl(ProdIODetail.pd_ordercode,' ')<>' ' "
|
|
|
+ + " and pd_piclass in ('采购验收单','采购验退单')", String.class, pi_id);
|
|
|
+ if (dets != null) {
|
|
|
+ BaseUtil.showError("明细行采购单所属工厂与仓库的所属工厂不一致,不允许进行当前操作!行号:" + dets);
|
|
|
+ }
|
|
|
+ // 生产领料单、退料单、补料单:明细行制造单所属工厂与仓库的所属工厂不一致,不允许进行当前操作
|
|
|
+ dets = baseDao
|
|
|
+ .getJdbcTemplate()
|
|
|
+ .queryForObject(
|
|
|
+ "select wm_concat(pd_pdno) from ProdIODetail left join Make on pd_ordercode=ma_code left join Warehouse on pd_whcode=wh_code left join product on ProdIODetail.pd_prodcode=pr_code where pd_piid=? and nvl(PR_ISGROUPPURC,0)=0 and nvl(ma_factory,' ')<>nvl(wh_factory,' ') and nvl(pd_ordercode,' ')<>' ' "
|
|
|
+ + "and pd_piclass in ('生产领料单','生产退料单','生产补料单')", String.class, pi_id);
|
|
|
+ if (dets != null) {
|
|
|
+ BaseUtil.showError("明细行制造单所属工厂与仓库的所属工厂不一致,不允许进行当前操作!行号:" + dets);
|
|
|
+ }
|
|
|
+ // 委外领料单、退料单、补料单:明细行委外单所属工厂与仓库的所属工厂不一致,不允许进行当前操作
|
|
|
+ dets = baseDao
|
|
|
+ .getJdbcTemplate()
|
|
|
+ .queryForObject(
|
|
|
+ "select wm_concat(pd_pdno) from ProdIODetail left join Make on pd_ordercode=ma_code left join Warehouse on pd_whcode=wh_code left join product on ProdIODetail.pd_prodcode=pr_code where pd_piid=? and nvl(PR_ISGROUPPURC,0)=0 and nvl(ma_factory,' ')<>nvl(wh_factory,' ') and nvl(pd_ordercode,' ')<>' ' "
|
|
|
+ + "and pd_piclass in ('委外领料单','委外退料单','委外补料单')", String.class, pi_id);
|
|
|
+ if (dets != null) {
|
|
|
+ BaseUtil.showError("明细行委外单所属工厂与仓库的所属工厂不一致,不允许进行当前操作!行号:" + dets);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // @add 20170524 出库类型的单据,保存,更新,获取批号之后更新备料状态
|
|
|
+ private void updatePdaStatus(String caller, Object pi_id) {
|
|
|
+ Boolean bo = baseDao.isDBSetting("BarCodeSetting", "BarRelevancyBatch");
|
|
|
+ if(!bo){
|
|
|
+ if (baseDao.isOut(caller)) { // 出库类型
|
|
|
+ // 如果所有的明细都没有条码则更新为空
|
|
|
+ SqlRowList rs = baseDao.queryForRowSet("select count(1)cn from prodiodetail where pd_piid=? and nvl(pd_batchcode,' ')<>' '",
|
|
|
+ pi_id);
|
|
|
+ if (rs.next() && rs.getInt("cn") == 0) {
|
|
|
+ baseDao.execute("update prodinout set pi_pdastatus='' where pi_id=? and nvl(pi_pdastatus,' ')<>' '", pi_id);
|
|
|
+ } else {
|
|
|
+ rs = baseDao.queryForRowSet("select count(1)cn from barcodeio where bi_piid=? and bi_outqty>0", pi_id);
|
|
|
+ if (rs.next() && rs.getInt("cn") > 0) { // 有一行以上备料记录则是备料中
|
|
|
+ baseDao.execute("update prodinout set pi_pdastatus ='备料中' where pi_id=?", pi_id);
|
|
|
+ rs = baseDao
|
|
|
+ .queryForRowSet(
|
|
|
+ "select count(1) cn from (select pd_prodcode,pd_whcode,sum(pd_outqty)qty from prodiodetail left join batch on pd_batchid=ba_id "
|
|
|
+ + " where pd_piid=? and ba_hasbarcode<>0 group by pd_prodcode,pd_whcode)A left join (select bi_prodcode,bi_whcode,sum(bi_outqty)qty "
|
|
|
+ + " from barcodeio where bi_piid=? group by bi_prodcode,bi_whcode)B on (pd_prodcode=bi_prodcode and pd_whcode=bi_whcode) where A.qty>NVL(B.qty,0)",
|
|
|
+ pi_id, pi_id);
|
|
|
+ if (rs.next() && rs.getInt("cn") == 0) {
|
|
|
+ baseDao.execute("update prodinout set pi_pdastatus ='已备料' where pi_id=?", pi_id);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // --存在有条码的批号则更新成未备料
|
|
|
+ baseDao.execute(
|
|
|
+ "update prodinout set pi_pdastatus ='未备料' where pi_id=? and exists(select 1 from prodiodetail,batch where pd_piid=? and pd_batchid=ba_id and ba_hasbarcode<>0)",
|
|
|
+ pi_id, pi_id);
|
|
|
+ // --所有批号都无条码则更新成无条码
|
|
|
+ baseDao.execute(
|
|
|
+ "update prodinout set pi_pdastatus ='无条码' where pi_id=? and not exists(select 1 from prodiodetail left join batch on ba_id=pd_batchid where pd_piid=? and ba_hasbarcode=-1)",
|
|
|
+ pi_id, pi_id);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private String List2Str(List<Object> list){
|
|
|
+ StringBuffer sb = new StringBuffer();
|
|
|
+ for (Object field : list) {
|
|
|
+ if (field != null) {
|
|
|
+ //处理字段前带有表名以及最后多了一个空格的字段
|
|
|
+ String f = field.toString().trim();
|
|
|
+ int i = f.lastIndexOf(" ");
|
|
|
+ sb.append(f.substring(i + 1) + ",");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (sb.length()>1)
|
|
|
+ return sb.substring(0, sb.length()-1);
|
|
|
+ else return null;
|
|
|
+ }
|
|
|
+}
|